Update OTLP protobufs to v0.13.0-alpha (#4170)
and add documentation on how to update that dependency.
This commit is contained in:
parent
34d75aa260
commit
f7c52e181e
193
CONTRIBUTING.md
193
CONTRIBUTING.md
|
@ -21,26 +21,25 @@ used on Java 8 or higher.
|
|||
|
||||
## Building opentelemetry-java
|
||||
|
||||
Continuous integration builds the project, runs the tests, and runs multiple
|
||||
types of static analysis.
|
||||
Continuous integration builds the project, runs the tests, and runs multiple types of static
|
||||
analysis.
|
||||
|
||||
1. Note: Currently, to run the full suite of tests, you'll need to be running a docker daemon.
|
||||
The tests that require docker are disabled if docker is not present. If you wish to run them,
|
||||
you must run a local docker daemon.
|
||||
1. Note: Currently, to run the full suite of tests, you'll need to be running a docker daemon. The
|
||||
tests that require docker are disabled if docker is not present. If you wish to run them, you
|
||||
must run a local docker daemon.
|
||||
|
||||
2. Clone the repository
|
||||
|
||||
`git clone https://github.com/open-telemetry/opentelemetry-java.git`
|
||||
`git clone https://github.com/open-telemetry/opentelemetry-java.git`
|
||||
|
||||
3. Run the following commands to build, run tests and most static analysis, and
|
||||
check formatting:
|
||||
3. Run the following commands to build, run tests and most static analysis, and check formatting:
|
||||
|
||||
`./gradlew build`
|
||||
`./gradlew build`
|
||||
|
||||
4. If you are a Windows user, use the alternate command mentioned below to run tests and
|
||||
check formatting:
|
||||
4. If you are a Windows user, use the alternate command mentioned below to run tests and check
|
||||
formatting:
|
||||
|
||||
`gradlew.bat`
|
||||
`gradlew.bat`
|
||||
|
||||
## Checks
|
||||
|
||||
|
@ -51,91 +50,101 @@ with the `check` task.
|
|||
$ ./gradlew check
|
||||
```
|
||||
|
||||
Note: this gradle task will potentially generate changes to files in the `docs/apidiffs/current_vs_latest`
|
||||
Note: this gradle task will potentially generate changes to files in
|
||||
the `docs/apidiffs/current_vs_latest`
|
||||
directory. Please make sure to include any changes to these files in your pull request.
|
||||
|
||||
## PR Review
|
||||
After you submit a PR, it will be reviewed by the project maintainers and approvers. Not all maintainers need to review a
|
||||
particular PR, but merging to the base branch is authorized to restricted members (administrators).
|
||||
|
||||
After you submit a PR, it will be reviewed by the project maintainers and approvers. Not all
|
||||
maintainers need to review a particular PR, but merging to the base branch is authorized to
|
||||
restricted members (administrators).
|
||||
|
||||
## Style guideline
|
||||
|
||||
We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
|
||||
Our build will fail if source code is not formatted according to that style. To fix any
|
||||
style failures the above [checks](#checks) show, automatically apply the formatting with:
|
||||
We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Our
|
||||
build will fail if source code is not formatted according to that style. To fix any style failures
|
||||
the above [checks](#checks) show, automatically apply the formatting with:
|
||||
|
||||
```bash
|
||||
$ ./gradlew spotlessApply
|
||||
```
|
||||
|
||||
To verify code style manually run the following command,
|
||||
which uses [google-java-format](https://github.com/google/google-java-format) library:
|
||||
To verify code style manually run the following command, which
|
||||
uses [google-java-format](https://github.com/google/google-java-format) library:
|
||||
|
||||
`./gradlew spotlessCheck`
|
||||
|
||||
### Best practices that we follow
|
||||
|
||||
* This project uses [semantic versioning](https://semver.org/). Except for major versions, a user should be able to update
|
||||
their dependency version on this project and have nothing break. This means we do not make breaking
|
||||
changes to the API (e.g., remove a public method) or to the ABI (e.g., change return type from void to non-void).
|
||||
* This project uses [semantic versioning](https://semver.org/). Except for major versions, a user
|
||||
should be able to update their dependency version on this project and have nothing break. This
|
||||
means we do not make breaking changes to the API (e.g., remove a public method) or to the ABI (
|
||||
e.g., change return type from void to non-void).
|
||||
* Avoid exposing publicly any class/method/variable that don't need to be public.
|
||||
* By default, all arguments/members are treated as non-null. Every argument/member that can be `null` must be annotated with `@Nullable`.
|
||||
* The project aims to provide a consistent experience across all the public APIs. It is important to ensure consistency (same look and feel) across different public packages.
|
||||
* Use `final` for public classes everywhere it is possible, this ensures that these classes cannot be extended when the API does not intend to offer that functionality.
|
||||
* By default, all arguments/members are treated as non-null. Every argument/member that can
|
||||
be `null` must be annotated with `@Nullable`.
|
||||
* The project aims to provide a consistent experience across all the public APIs. It is important to
|
||||
ensure consistency (same look and feel) across different public packages.
|
||||
* Use `final` for public classes everywhere it is possible, this ensures that these classes cannot
|
||||
be extended when the API does not intend to offer that functionality.
|
||||
* In general, we use the following ordering of class members:
|
||||
* Static fields (final before non-final)
|
||||
* Instance fields (final before non-final)
|
||||
* Constructors
|
||||
* In static utility classes (where all members are static), the private constructor
|
||||
(used to prevent construction) should be ordered after methods instead of before methods.
|
||||
* Methods
|
||||
* If methods call each other, it's nice if the calling method is ordered (somewhere) above
|
||||
the method that it calls. So, for one example, a private method would be ordered (somewhere) below
|
||||
the non-private methods that use it.
|
||||
* Nested classes
|
||||
* Adding `toString()` overrides on classes is encouraged, but we only use `toString()` to provide debugging assistance. The implementations
|
||||
of all `toString()` methods should be considered to be unstable unless explicitly documented otherwise.
|
||||
* Static fields (final before non-final)
|
||||
* Instance fields (final before non-final)
|
||||
* Constructors
|
||||
* In static utility classes (where all members are static), the private constructor
|
||||
(used to prevent construction) should be ordered after methods instead of before methods.
|
||||
* Methods
|
||||
* If methods call each other, it's nice if the calling method is ordered (somewhere) above the
|
||||
method that it calls. So, for one example, a private method would be ordered (somewhere) below
|
||||
the non-private methods that use it.
|
||||
* Nested classes
|
||||
* Adding `toString()` overrides on classes is encouraged, but we only use `toString()` to provide
|
||||
debugging assistance. The implementations of all `toString()` methods should be considered to be
|
||||
unstable unless explicitly documented otherwise.
|
||||
|
||||
If you notice any practice being applied in the project consistently that isn't listed here, please consider a pull request to add it.
|
||||
If you notice any practice being applied in the project consistently that isn't listed here, please
|
||||
consider a pull request to add it.
|
||||
|
||||
### Pre-commit hook
|
||||
To completely delegate code style formatting to the machine,
|
||||
you can add [git pre-commit hook](https://git-scm.com/docs/githooks).
|
||||
We provide an example script in `buildscripts/pre-commit` file.
|
||||
Just copy or symlink it into `.git/hooks` folder.
|
||||
|
||||
To completely delegate code style formatting to the machine, you can
|
||||
add [git pre-commit hook](https://git-scm.com/docs/githooks). We provide an example script
|
||||
in `buildscripts/pre-commit` file. Just copy or symlink it into `.git/hooks` folder.
|
||||
|
||||
### Editorconfig
|
||||
As additional convenience for IntelliJ Idea users, we provide `.editorconfig` file.
|
||||
Idea will automatically use it to adjust its code formatting settings.
|
||||
It does not support all required rules, so you still have to run `spotlessApply` from time to time.
|
||||
|
||||
As additional convenience for IntelliJ Idea users, we provide `.editorconfig` file. Idea will
|
||||
automatically use it to adjust its code formatting settings. It does not support all required rules,
|
||||
so you still have to run `spotlessApply` from time to time.
|
||||
|
||||
### Javadoc
|
||||
|
||||
* All public classes and their public and protected methods MUST have javadoc.
|
||||
It MUST be complete (all params documented etc.) Everything else
|
||||
(package-protected classes, private) MAY have javadoc, at the code writer's
|
||||
whim. It does not have to be complete, and reviewers are not allowed to
|
||||
require or disallow it.
|
||||
* Each API element should have a `@since` tag specifying the minor version when
|
||||
it was released (or the next minor version).
|
||||
* All public classes and their public and protected methods MUST have javadoc. It MUST be complete (
|
||||
all params documented etc.) Everything else
|
||||
(package-protected classes, private) MAY have javadoc, at the code writer's whim. It does not have
|
||||
to be complete, and reviewers are not allowed to require or disallow it.
|
||||
* Each API element should have a `@since` tag specifying the minor version when it was released (or
|
||||
the next minor version).
|
||||
* There MUST be NO javadoc errors.
|
||||
* See [section
|
||||
7.3.1](https://google.github.io/styleguide/javaguide.html#s7.3.1-javadoc-exception-self-explanatory)
|
||||
in the guide for exceptions to the Javadoc requirement.
|
||||
* Reviewers may request documentation for any element that doesn't require
|
||||
Javadoc, though the style of documentation is up to the author.
|
||||
* Try to do the least amount of change when modifying existing documentation.
|
||||
Don't change the style unless you have a good reason.
|
||||
*
|
||||
|
||||
See [section 7.3.1](https://google.github.io/styleguide/javaguide.html#s7.3.1-javadoc-exception-self-explanatory)
|
||||
in the guide for exceptions to the Javadoc requirement.
|
||||
|
||||
* Reviewers may request documentation for any element that doesn't require Javadoc, though the style
|
||||
of documentation is up to the author.
|
||||
* Try to do the least amount of change when modifying existing documentation. Don't change the style
|
||||
unless you have a good reason.
|
||||
* We do not use `@author` tags in our javadoc.
|
||||
* Our javadoc is available via [javadoc.io}(https://javadoc.io/doc/io.opentelemetry/opentelemetry-api)
|
||||
* Our javadoc is available via [
|
||||
javadoc.io}(https://javadoc.io/doc/io.opentelemetry/opentelemetry-api)
|
||||
|
||||
### AutoValue
|
||||
|
||||
* Use [AutoValue](https://github.com/google/auto/tree/master/value), when
|
||||
possible, for any new value classes. Remember to add package-private
|
||||
constructors to all AutoValue classes to prevent classes in other packages
|
||||
from extending them.
|
||||
|
||||
* Use [AutoValue](https://github.com/google/auto/tree/master/value), when possible, for any new
|
||||
value classes. Remember to add package-private constructors to all AutoValue classes to prevent
|
||||
classes in other packages from extending them.
|
||||
|
||||
### Unit Tests
|
||||
|
||||
|
@ -145,35 +154,41 @@ It does not support all required rules, so you still have to run `spotlessApply`
|
|||
|
||||
### Updating the Snapshot build number
|
||||
|
||||
The overall version number for opentelemetry-java is determined from git tags, and not fixed in any file.
|
||||
The overall version number for opentelemetry-java is determined from git tags, and not fixed in any
|
||||
file.
|
||||
|
||||
This means it will not update, even if you `git pull` from the repo tip. It will still produce a set of libraries with the old version number.
|
||||
This means it will not update, even if you `git pull` from the repo tip. It will still produce a set
|
||||
of libraries with the old version number.
|
||||
|
||||
To update it, you must fetch the tags, via `git fetch --all --tags` - which should work, even if you have forked the repo, as long as the trunk repo is set as an upstream remote.
|
||||
To update it, you must fetch the tags, via `git fetch --all --tags` - which should work, even if you
|
||||
have forked the repo, as long as the trunk repo is set as an upstream remote.
|
||||
|
||||
### Updating OTLP proto dependency version
|
||||
|
||||
The OTLP proto dependency version is defined [here](proto/build.gradle). To bump the version,
|
||||
|
||||
1. Find the latest release version [here](https://github.com/open-telemetry/opentelemetry-proto/releases/latest)
|
||||
1. Find the latest release
|
||||
version [here](https://github.com/open-telemetry/opentelemetry-proto/releases/latest)
|
||||
2. Download the zip source code archive
|
||||
3. Run `shasum -a 256 ~/path/to/downloaded.zip` to compute its checksum
|
||||
4. Update `protoVersion` and `protoChecksum` in the build file with the new version and checksum
|
||||
|
||||
### Composing builds
|
||||
|
||||
Beware that this section is only meant for developers of opentelemetry-java, or closely related projects.
|
||||
The steps described here could change at any time and what you do for one version (commit) may break
|
||||
with the next one already.
|
||||
Beware that this section is only meant for developers of opentelemetry-java, or closely related
|
||||
projects. The steps described here could change at any time and what you do for one version (commit)
|
||||
may break with the next one already.
|
||||
|
||||
Gradle provides a feature called ["composite builds"](https://docs.gradle.org/current/userguide/composite_builds.html)
|
||||
Gradle provides a feature
|
||||
called ["composite builds"](https://docs.gradle.org/current/userguide/composite_builds.html)
|
||||
that allows to replace some normally externally provided dependencies with a project that is built
|
||||
(included) in the same Gradle invocation. This can be useful to quickly test a new feature or bug fix you are
|
||||
developing in opentelemetry-java with the examples or the app or instrumentation library where you
|
||||
need the feature or run into the bug. Unfortunately, opentelemetry-java does not work out of the box
|
||||
with this feature because Gradle is unable to map the project names to the customized artifact
|
||||
coordinates (see e.g. [gradle/gradle#18291](https://github.com/gradle/gradle/issues/18291)
|
||||
and related issues. However, gradle supports manually declaring the mapping between ("substitution of")
|
||||
(included) in the same Gradle invocation. This can be useful to quickly test a new feature or bug
|
||||
fix you are developing in opentelemetry-java with the examples or the app or instrumentation library
|
||||
where you need the feature or run into the bug. Unfortunately, opentelemetry-java does not work out
|
||||
of the box with this feature because Gradle is unable to map the project names to the customized
|
||||
artifact coordinates (see e.g. [gradle/gradle#18291](https://github.com/gradle/gradle/issues/18291)
|
||||
and related issues. However, gradle supports manually declaring the mapping between ("substitution
|
||||
of")
|
||||
artifact coordinates and project names. To ease this tedious task, opentelemetry-java provides a
|
||||
gradle task `:generateBuildSubstitutions` that generates a code snippet with these substitutions in
|
||||
kts (Kotlin Script) format.
|
||||
|
@ -200,6 +215,18 @@ Example usage could be as follows:
|
|||
See [the Gradle documentation](https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions)
|
||||
for more information.
|
||||
|
||||
4. If you now build your project, it will use the included build to supply the opentelemetry-java artifacts,
|
||||
ignoring any version declarations. Use the prefix `:DIRECTORY:` to refer to tasks/projects within
|
||||
the included build, where DIRECTORY is the name of the directory in the included build (only the part after the last `/`).
|
||||
4. If you now build your project, it will use the included build to supply the opentelemetry-java
|
||||
artifacts, ignoring any version declarations. Use the prefix `:DIRECTORY:` to refer to
|
||||
tasks/projects within the included build, where DIRECTORY is the name of the directory in the
|
||||
included build (only the part after the last `/`).
|
||||
|
||||
### Updating the OTLP protobufs
|
||||
|
||||
OTLP protobuf Java bindings are published via
|
||||
the [opentelemetry-proto-java](https://github.com/open-telemetry/opentelemetry-proto-java)
|
||||
repository. This project does not use the java bindings, but does use the `.proto` files that are
|
||||
published in the binding jar by that project.
|
||||
|
||||
To update the OTLP protobuf version,
|
||||
first [release a new version of the java bindings](https://github.com/open-telemetry/opentelemetry-proto-java/blob/main/RELEASING.md)
|
||||
then simply update the dependency version that this project has on that jar.
|
||||
|
|
|
@ -87,7 +87,7 @@ val DEPENDENCIES = listOf(
|
|||
"eu.rekawek.toxiproxy:toxiproxy-java:2.1.5",
|
||||
"io.github.netmikey.logunit:logunit-jul:1.1.3",
|
||||
"io.jaegertracing:jaeger-client:1.8.0",
|
||||
"io.opentelemetry.proto:opentelemetry-proto:0.11.0-alpha",
|
||||
"io.opentelemetry.proto:opentelemetry-proto:0.13.0-alpha",
|
||||
"io.opentracing:opentracing-api:0.33.0",
|
||||
"junit:junit:4.13.2",
|
||||
"nl.jqno.equalsverifier:equalsverifier:3.9",
|
||||
|
|
|
@ -87,6 +87,7 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
assertThat(logs.getEvents())
|
||||
.hasSize(1)
|
||||
.allSatisfy(log -> assertThat(log.getLevel()).isEqualTo(Level.INFO));
|
||||
String message = logs.getEvents().get(0).getMessage();
|
||||
JSONAssert.assertEquals(
|
||||
"{\n"
|
||||
+ " \"resource\":{\n"
|
||||
|
@ -105,7 +106,7 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
+ " \"name\":\"instrumentation2\",\n"
|
||||
+ " \"version\":\"2\"\n"
|
||||
+ " },\n"
|
||||
+ " \"logs\":[\n"
|
||||
+ " \"logRecords\":[\n"
|
||||
+ " {\n"
|
||||
+ " \"timeUnixNano\":\"1631533710000000\",\n"
|
||||
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\",\n"
|
||||
|
@ -132,7 +133,7 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
+ " \"name\":\"instrumentation\",\n"
|
||||
+ " \"version\":\"1\"\n"
|
||||
+ " },\n"
|
||||
+ " \"logs\":[\n"
|
||||
+ " \"logRecords\":[\n"
|
||||
+ " {\n"
|
||||
+ " \"timeUnixNano\":\"1631533710000000\",\n"
|
||||
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\",\n"
|
||||
|
@ -162,9 +163,9 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
+ " }\n"
|
||||
+ " ]\n"
|
||||
+ "}",
|
||||
logs.getEvents().get(0).getMessage(),
|
||||
message,
|
||||
/* strict= */ false);
|
||||
assertThat(logs.getEvents().get(0).getMessage()).doesNotContain("\n");
|
||||
assertThat(message).doesNotContain("\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -101,6 +101,7 @@ class OtlpJsonLoggingSpanExporterTest {
|
|||
assertThat(logs.getEvents())
|
||||
.hasSize(1)
|
||||
.allSatisfy(log -> assertThat(log.getLevel()).isEqualTo(Level.INFO));
|
||||
String message = logs.getEvents().get(0).getMessage();
|
||||
JSONAssert.assertEquals(
|
||||
"{"
|
||||
+ " \"resource\": {"
|
||||
|
@ -124,7 +125,6 @@ class OtlpJsonLoggingSpanExporterTest {
|
|||
+ " \"startTimeUnixNano\": \"500\","
|
||||
+ " \"endTimeUnixNano\": \"1501\","
|
||||
+ " \"status\": {"
|
||||
+ " \"deprecatedCode\": \"DEPRECATED_STATUS_CODE_UNKNOWN_ERROR\","
|
||||
+ " \"code\": \"STATUS_CODE_ERROR\""
|
||||
+ " }"
|
||||
+ " }]"
|
||||
|
@ -167,9 +167,9 @@ class OtlpJsonLoggingSpanExporterTest {
|
|||
+ " }]"
|
||||
+ " }]"
|
||||
+ "}",
|
||||
logs.getEvents().get(0).getMessage(),
|
||||
message,
|
||||
/* strict= */ false);
|
||||
assertThat(logs.getEvents().get(0).getMessage()).doesNotContain("\n");
|
||||
assertThat(message).doesNotContain("\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -33,7 +33,7 @@ final class InstrumentationLibraryLogsMarshaler extends MarshalerWithSize {
|
|||
public void writeTo(Serializer output) throws IOException {
|
||||
output.serializeMessage(
|
||||
InstrumentationLibraryLogs.INSTRUMENTATION_LIBRARY, instrumentationLibrary);
|
||||
output.serializeRepeatedMessage(InstrumentationLibraryLogs.LOGS, logMarshalers);
|
||||
output.serializeRepeatedMessage(InstrumentationLibraryLogs.LOG_RECORDS, logMarshalers);
|
||||
output.serializeString(InstrumentationLibraryLogs.SCHEMA_URL, schemaUrlUtf8);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,8 @@ final class InstrumentationLibraryLogsMarshaler extends MarshalerWithSize {
|
|||
MarshalerUtil.sizeMessage(
|
||||
InstrumentationLibraryLogs.INSTRUMENTATION_LIBRARY, instrumentationLibrary);
|
||||
size += MarshalerUtil.sizeBytes(InstrumentationLibraryLogs.SCHEMA_URL, schemaUrlUtf8);
|
||||
size += MarshalerUtil.sizeRepeatedMessage(InstrumentationLibraryLogs.LOGS, logMarshalers);
|
||||
size +=
|
||||
MarshalerUtil.sizeRepeatedMessage(InstrumentationLibraryLogs.LOG_RECORDS, logMarshalers);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,41 +16,33 @@ import java.io.IOException;
|
|||
|
||||
final class SpanStatusMarshaler extends MarshalerWithSize {
|
||||
private final ProtoEnumInfo protoStatusCode;
|
||||
private final ProtoEnumInfo deprecatedStatusCode;
|
||||
private final byte[] descriptionUtf8;
|
||||
|
||||
static SpanStatusMarshaler create(StatusData status) {
|
||||
ProtoEnumInfo protoStatusCode = Status.StatusCode.STATUS_CODE_UNSET;
|
||||
ProtoEnumInfo deprecatedStatusCode = Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_OK;
|
||||
if (status.getStatusCode() == StatusCode.OK) {
|
||||
protoStatusCode = Status.StatusCode.STATUS_CODE_OK;
|
||||
} else if (status.getStatusCode() == StatusCode.ERROR) {
|
||||
protoStatusCode = Status.StatusCode.STATUS_CODE_ERROR;
|
||||
deprecatedStatusCode = Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR;
|
||||
}
|
||||
byte[] description = MarshalerUtil.toBytes(status.getDescription());
|
||||
return new SpanStatusMarshaler(protoStatusCode, deprecatedStatusCode, description);
|
||||
return new SpanStatusMarshaler(protoStatusCode, description);
|
||||
}
|
||||
|
||||
private SpanStatusMarshaler(
|
||||
ProtoEnumInfo protoStatusCode, ProtoEnumInfo deprecatedStatusCode, byte[] descriptionUtf8) {
|
||||
super(computeSize(protoStatusCode, deprecatedStatusCode, descriptionUtf8));
|
||||
private SpanStatusMarshaler(ProtoEnumInfo protoStatusCode, byte[] descriptionUtf8) {
|
||||
super(computeSize(protoStatusCode, descriptionUtf8));
|
||||
this.protoStatusCode = protoStatusCode;
|
||||
this.deprecatedStatusCode = deprecatedStatusCode;
|
||||
this.descriptionUtf8 = descriptionUtf8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(Serializer output) throws IOException {
|
||||
output.serializeEnum(Status.DEPRECATED_CODE, deprecatedStatusCode);
|
||||
output.serializeString(Status.MESSAGE, descriptionUtf8);
|
||||
output.serializeEnum(Status.CODE, protoStatusCode);
|
||||
}
|
||||
|
||||
private static int computeSize(
|
||||
ProtoEnumInfo protoStatusCode, ProtoEnumInfo deprecatedStatusCode, byte[] descriptionUtf8) {
|
||||
private static int computeSize(ProtoEnumInfo protoStatusCode, byte[] descriptionUtf8) {
|
||||
int size = 0;
|
||||
size += MarshalerUtil.sizeEnum(Status.DEPRECATED_CODE, deprecatedStatusCode);
|
||||
size += MarshalerUtil.sizeBytes(Status.MESSAGE, descriptionUtf8);
|
||||
size += MarshalerUtil.sizeEnum(Status.CODE, protoStatusCode);
|
||||
return size;
|
||||
|
|
|
@ -178,7 +178,7 @@ class LogsRequestMarshalerTest {
|
|||
ResourceLogs.Builder fixed = (ResourceLogs.Builder) builder;
|
||||
for (InstrumentationLibraryLogs.Builder ill :
|
||||
fixed.getInstrumentationLibraryLogsBuilderList()) {
|
||||
for (LogRecord.Builder span : ill.getLogsBuilderList()) {
|
||||
for (LogRecord.Builder span : ill.getLogRecordsBuilderList()) {
|
||||
fixSpanJsonIds(span);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ package io.opentelemetry.exporter.internal.otlp.traces;
|
|||
|
||||
import static io.opentelemetry.api.common.AttributeKey.stringKey;
|
||||
import static io.opentelemetry.proto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER;
|
||||
import static io.opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_OK;
|
||||
import static io.opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR;
|
||||
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_ERROR;
|
||||
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_OK;
|
||||
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_UNSET;
|
||||
|
@ -229,45 +227,24 @@ class TraceRequestMarshalerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
// setDeprecatedCode is deprecated.
|
||||
void toProtoStatus() {
|
||||
assertThat(parse(Status.getDefaultInstance(), SpanStatusMarshaler.create(StatusData.unset())))
|
||||
.isEqualTo(
|
||||
Status.newBuilder()
|
||||
.setCode(STATUS_CODE_UNSET)
|
||||
.setDeprecatedCode(DEPRECATED_STATUS_CODE_OK)
|
||||
.build());
|
||||
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_UNSET).build());
|
||||
assertThat(
|
||||
parse(
|
||||
Status.getDefaultInstance(),
|
||||
SpanStatusMarshaler.create(StatusData.create(StatusCode.ERROR, "ERROR"))))
|
||||
.isEqualTo(
|
||||
Status.newBuilder()
|
||||
.setCode(STATUS_CODE_ERROR)
|
||||
.setDeprecatedCode(DEPRECATED_STATUS_CODE_UNKNOWN_ERROR)
|
||||
.setMessage("ERROR")
|
||||
.build());
|
||||
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_ERROR).setMessage("ERROR").build());
|
||||
assertThat(
|
||||
parse(
|
||||
Status.getDefaultInstance(),
|
||||
SpanStatusMarshaler.create(StatusData.create(StatusCode.ERROR, "UNKNOWN"))))
|
||||
.isEqualTo(
|
||||
Status.newBuilder()
|
||||
.setCode(STATUS_CODE_ERROR)
|
||||
.setDeprecatedCode(DEPRECATED_STATUS_CODE_UNKNOWN_ERROR)
|
||||
.setMessage("UNKNOWN")
|
||||
.build());
|
||||
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_ERROR).setMessage("UNKNOWN").build());
|
||||
assertThat(
|
||||
parse(
|
||||
Status.getDefaultInstance(),
|
||||
SpanStatusMarshaler.create(StatusData.create(StatusCode.OK, "OK_OVERRIDE"))))
|
||||
.isEqualTo(
|
||||
Status.newBuilder()
|
||||
.setCode(STATUS_CODE_OK)
|
||||
.setDeprecatedCode(DEPRECATED_STATUS_CODE_OK)
|
||||
.setMessage("OK_OVERRIDE")
|
||||
.build());
|
||||
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_OK).setMessage("OK_OVERRIDE").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -415,9 +415,9 @@ abstract class OtlpExporterIntegrationTest {
|
|||
InstrumentationLibraryLogs ilLogs = resourceLogs.getInstrumentationLibraryLogs(0);
|
||||
assertThat(ilLogs.getInstrumentationLibrary().getName())
|
||||
.isEqualTo(OtlpExporterIntegrationTest.class.getName());
|
||||
assertThat(ilLogs.getLogsCount()).isEqualTo(1);
|
||||
assertThat(ilLogs.getLogRecordsCount()).isEqualTo(1);
|
||||
|
||||
io.opentelemetry.proto.logs.v1.LogRecord protoLog = ilLogs.getLogs(0);
|
||||
io.opentelemetry.proto.logs.v1.LogRecord protoLog = ilLogs.getLogRecords(0);
|
||||
assertThat(protoLog.getName()).isEqualTo("log-name");
|
||||
assertThat(protoLog.getBody().getStringValue()).isEqualTo("log body");
|
||||
assertThat(protoLog.getAttributesList())
|
||||
|
|
|
@ -281,7 +281,7 @@ class FullConfigTest {
|
|||
.setValue(AnyValue.newBuilder().setStringValue("meow").build())
|
||||
.build());
|
||||
// MetricExporterCustomizer filters logs not whose level is less than Severity.INFO
|
||||
LogRecord log = logRequest.getResourceLogs(0).getInstrumentationLibraryLogs(0).getLogs(0);
|
||||
LogRecord log = logRequest.getResourceLogs(0).getInstrumentationLibraryLogs(0).getLogRecords(0);
|
||||
assertThat(log.getBody().getStringValue()).isEqualTo("info log message");
|
||||
assertThat(log.getSeverityNumberValue()).isEqualTo(Severity.INFO.getSeverityNumber());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue