<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Monitoring Python Applications With Kieker</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Reiner Jung</string-name>
          <email>reiner.jung@email.uni-kiel.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Sven Gundlach</string-name>
          <email>sven.gundlach@email.uni-kiel.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Serafim Simnonov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Wilhelm Hasselbring</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Kiel Unversity</institution>
          ,
          <addr-line>Christian-Albrechts-Platz 4, 24103 Kiel</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Python is a widely used programming for applications, web services, and, especially, in scientific computing and data science. In the context of our project OceanDSL, which aims to provide DSLs for ocean system models, we need to comprehend existing scientific software based on static and dynamic code analysis. Thus, we decided to provide monitoring support for Python utilizing the existing Kieker analysis toolchain. As the code base is rather extensive, manually injecting probes is not a viable solution. Thus, our implementation relies on code weaving approaches. The Kieker Language Pack for Python follows, in principle, the Kieker architecture for monitoring with a reduced feature set [1]. It comprises (a) event types, (b) code to control probes and data storage, (c) probes to instrument the code, and (d) a techniques to introduce probes into a program without modifying the code manually. Event types for Python can be generated utilizing the Kieker instrumentation record language (IRL) which we extended to support Python [2]. Currently, the event types consist, like their Java counterparts, of a set of constants implementing default values, attributes, a constructor and a serialization method which utilizes a serialization helper to support multiple formats (cf. Listing 1). As the language pack is only used to monitor and log events in Python applications, it does not support features used to deserialize and manage events. However, this can be added later, if needed.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Application Level Monitoring</kwd>
        <kwd>Kieker</kwd>
        <kwd>Instrumentation</kwd>
        <kwd>Python</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Listing 1: Simplified OperationExecutionRecord
c l a s s O p e r a t i o n E x e c u t i o n R e c o r d :
__NO_OPERATION_SIGNATURE__ = " n o O p e r a t i o n "</p>
      <p>Logging, time keeping, and probe control are handled by a monitoring controller utilizing a
writer and a time controller following the Kieker architecture in a simplified adaptation. The
controller provides all the necessary functionality for monitoring probes. The writer controller
supports logging into files and transfer via TCP. The file logging serializes event types following
the Kieker text file format. The TCP logging utilizes the Kieker binary logging format, which is
also used by the Kieker Java implementation and Kieker Language Pack for C and Fortran. The
latter logging feature allows to transfer data to a dedicated logging computer and either store
the log data with the Kieker collector tool (the replacement for the Kieker data bridge) or feed
the information directly into an analysis.</p>
      <p>The probes follow the same general structure implementing advices which can be applied
manually or with diferent methods automatically. We implemented a basic set of probes and
tooling supplemented with documentation. To apply the probes, users can rely on our own
weaving technique which utilizes Python’s own weaving feature. This has the benefit that no
additional libraries must be used. Alternatively, Python aspectlib can be used which provides
convenient functions to weave probes into Python.1</p>
      <p>While the Kieker Language Pack for Python is in an early stage, we applied it successfully
to the Kieker bookstore example. The tooling is available on the github page of Kieker.2 Our
next steps are to complete the implementation to support trace and data flow monitoring for
Python. Furthermore, we aim to create an installation package for Python supporting pip to
reduce hurdles for users including ourselves, and apply it to various tools used in data science
including Juypter notebooks.</p>
      <p>Acknowledgments
Funded by the Deutsche Forschungsgemeinschaft (DFG – German Research Foundation), grant
no. HA 2038/8-1 – 425916241.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>W.</given-names>
            <surname>Hasselbring</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. van Hoorn</surname>
          </string-name>
          ,
          <article-title>Kieker: A monitoring framework for software engineering research</article-title>
          ,
          <source>Software Impacts</source>
          <volume>5</volume>
          (
          <year>2020</year>
          ). doi:
          <volume>10</volume>
          .1016/j.simpa.
          <year>2020</year>
          .
          <volume>100019</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>R.</given-names>
            <surname>Jung</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Wulf</surname>
          </string-name>
          ,
          <article-title>Advanced typing for the Kieker instrumentation languages</article-title>
          ,
          <source>in: Symposium on Software Performance</source>
          <year>2016</year>
          ,
          <year>2016</year>
          . URL: http://oceanrep.geomar.de/34626/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          1Aspectlib https://pypi.org/project/aspectlib/ 2Kieker Language Pack for Python https://github.com/silvergl/kieker-lang
          <string-name>
            <surname>-</surname>
          </string-name>
          pack-python/
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>