1 Star 0 Fork 0

Lovnx/opentelemetry-java-instrumentation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
javaagent-test-infra.md 1.65 KB
一键复制 编辑 原始数据 按行查看 历史

Understanding the javaagent instrumentation testing components

Javaagent instrumentation tests are run using a fully shaded -javaagent in order to perform the same bytecode instrumentation as when the agent is run against a normal app.

There are a few key components that make this possible, described below.

gradle/instrumentation.gradle

  • shades the instrumentation
  • adds jvm args to the test configuration
    • -javaagent:[agent for testing]
    • -Dotel.initializer.jar=[shaded instrumentation jar]

The otel.initializer.jar property is used to load the shaded instrumentation jar into the AgentClassLoader, so that the javaagent jar doesn't need to be re-built each time.

:testing:agent-exporter

This contains the span and metric exporters that are used.

These are in-memory exporters, so that the tests can verify the spans and metrics being exported.

These exporters and the in-memory data live in the AgentClassLoader, so tests must access them using reflection. To simplify this, they store the in-memory data using the OTLP protobuf objects, so that they can be serialized into byte arrays inside the AgentClassLoader, then passed back to the tests and deserialized inside their class loader where they can be verified. The :testing-common module (described below) hides this complexity from instrumentation test authors.

:agent-for-testing

This is a custom distro of the javaagent that embeds the :testing:agent-exporter.

:testing-common

This module provides methods to help verify the span and metric data produced by the instrumentation, hiding the complexity of accessing the in-memory exporters that live in the AgentClassLoader.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lovnx/opentelemetry-java-instrumentation.git
git@gitee.com:lovnx/opentelemetry-java-instrumentation.git
lovnx
opentelemetry-java-instrumentation
opentelemetry-java-instrumentation
main

搜索帮助