Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Blog Post: Collecting file-based Java logs with OpenTelemetry #5600

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

cyrille-leclerc
Copy link
Member

@cyrille-leclerc cyrille-leclerc commented Nov 13, 2024

This post presents how to use the new experimental-otlp/stdout export format introduced by OpenTelemetry Java Instrumentation (open-telemetry/opentelemetry-java#6675) to export application logs to files with full OpenTelemetry contextualization and ingest them with the OTel Collector File Log receiver and OTLP/JSON connector.

In this post, we explain how to configure the OTel Java instrumentation agent and the OTel Collector, including when deploying on K8s, to implement the end to end file based logs ingestion pipeline.

Blog Post Issue: #5606
SIG: java and specifications
Sponsor:

Preview: https://deploy-preview-5600--opentelemetry.netlify.app/blog/2024/collecting-file-based-java-logs-with-opentelemetry/

@cyrille-leclerc cyrille-leclerc requested a review from a team as a code owner November 13, 2024 10:02
@github-actions github-actions bot added the blog label Nov 13, 2024
@opentelemetrybot opentelemetrybot requested a review from a team November 13, 2024 10:03
@zeitlinger
Copy link
Member

zeitlinger commented Nov 13, 2024

@cyrille-leclerc https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v2.10.0 was just released - I'll update the executable example in grafana/docker-otel-lgtm#145 now

@svrnm
Copy link
Member

svrnm commented Nov 13, 2024

@cyrille-leclerc can you raise an issue for this PR following our guidelines? Thanks

@cyrille-leclerc
Copy link
Member Author

@cyrille-leclerc can you raise an issue for this PR following our guidelines? Thanks

Thanks @svrnm. Please find the blog post issue:

content-modules/opentelemetry-specification Outdated Show resolved Hide resolved

![OTLP/JSON Architecture](otlpjson-architecture.png)

## Configure Java Application to Output OTLP/JSON Logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sample application you are using, is this available somewhere? If so, can you point to it? It's always good if people can reproduce your tutorial 1:1 without the need for them to find an application first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeitlinger do we have a simplified demo or we use https://github.com/cyrille-leclerc/my-shopping-cart/? Note that I reverted my-shopping-cart to the otlp exporter so I would have to spend a few cycles to setup a demo.

Comment on lines 90 to 92
![OpenTelemetry Collector OTLP/JSON pipeline](otel-collector-otlpjson-pipeline.png)

Source: [https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you provide the link to the otelbin source of that image, but let's figure out a way to visualize this better.

Copy link
Member Author

@cyrille-leclerc cyrille-leclerc Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![OpenTelemetry Collector OTLP/JSON pipeline](otel-collector-otlpjson-pipeline.png)
Source: [https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)
[View OTel Collector pipeline with <img src="https://www.otelbin.io/favicon.ico" height="20px"/> OTelBin](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)

@svrnm please review proposal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![OpenTelemetry Collector OTLP/JSON pipeline](otel-collector-otlpjson-pipeline.png)
Source: [https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)
{{< figure class="figure" src="otel-collector-otlpjson-pipeline.png" attr="View OTel Collector pipeline with OTelBin" attrlink="https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a" >}}

What I meant is to have something that makes it clearer that the Source: (or View ...) belongs to the image, since the spacing is not right, similar to what bootstrap provides for figures. We have a shortcode for that via docsy, it's not exactly what I want, but we can take a look into that separately, cc @chalin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@opentelemetrybot opentelemetrybot requested a review from a team November 15, 2024 11:09

![OTLP/JSON Architecture](otlpjson-architecture.png)

## Configure Java Application to Output OTLP/JSON Logs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeitlinger do we have a simplified demo or we use https://github.com/cyrille-leclerc/my-shopping-cart/? Note that I reverted my-shopping-cart to the otlp exporter so I would have to spend a few cycles to setup a demo.

Comment on lines 90 to 92
![OpenTelemetry Collector OTLP/JSON pipeline](otel-collector-otlpjson-pipeline.png)

Source: [https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)
Copy link
Member Author

@cyrille-leclerc cyrille-leclerc Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![OpenTelemetry Collector OTLP/JSON pipeline](otel-collector-otlpjson-pipeline.png)
Source: [https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)
[View OTel Collector pipeline with <img src="https://www.otelbin.io/favicon.ico" height="20px"/> OTelBin](https://www.otelbin.io/s/69739d790cf279c203fc8efc86ad1a876a2fc01a)

@svrnm please review proposal

@opentelemetrybot opentelemetrybot requested a review from a team November 18, 2024 10:35
Copy link
Contributor

@tiffany76 tiffany76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few copyedit suggestions. Thanks!

@opentelemetrybot opentelemetrybot requested a review from a team November 20, 2024 07:35
@opentelemetrybot opentelemetrybot requested a review from a team November 20, 2024 08:50
Comment on lines +49 to +50
## Reference architecture

The deployment architecture looks like the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need a section heading here, you're only introducing the diagram.

Also, this isn't a "reference architecture", nor even a "deployment architecture". Prefer the use of the simpler term "deployment diagram". Actually, if you just present the diagram, you don't really need to name it, but if you do (e.g., via the "alt" text in the image element below, then avoid the use of "architecture".

Suggested change
## Reference architecture
The deployment architecture looks like the following:


The deployment architecture looks like the following:

![OTLP/JSON Architecture](otlpjson-architecture.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diagram is really busy, and the content too small. I'd suggest the following improvements:

  • Remove the following text from the diagram and add it instead as prose to this section (before or after the image):
    • "Logs contextualized with OTel metadata including: ..."
    • "experimental-otlp/stout" exporter Available in Java Agent v2.10"
  • Move the "Observability Platform" block to be below the rest so that the image becomes less wide -- that is, favor vertical image real estate rather than horizontal. Or, if you prefer, put the app at the top of the diagram with the OTel components below. Something (very roughly) like what I show below.
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of this style?
image

Comment on lines +111 to +116
<!-- prettier-ignore-start -->

```json
{"resourceLogs":[{"resource":{"attributes":[{"key":"deployment.environment.name","value":{"stringValue":"staging"}},{"key":"service.instance.id","value":{"stringValue":"6ad88e10-238c-4fb7-bf97-38df19053366"}},{"key":"service.name","value":{"stringValue":"checkout"}},{"key":"service.namespace","value":{"stringValue":"shop"}},{"key":"service.version","value":{"stringValue":"1.1"}}]},"scopeLogs":[{"scope":{"name":"com.mycompany.checkout.CheckoutServiceServer$CheckoutServiceImpl","attributes":[]},"logRecords":[{"timeUnixNano":"1730435085776869000","observedTimeUnixNano":"1730435085776944000","severityNumber":9,"severityText":"INFO","body":{"stringValue":"Order order-12035 successfully placed"}, "attributes":[{"key":"customerId","value":{"stringValue":"customer-49"}},{"key":"thread.id","value":{"intValue":"44"}},{"key":"thread.name","value":{"stringValue":"grpc-default-executor-1"}}],"flags":1,"traceId":"42de1f0dd124e27619a9f3c10bccac1c","spanId":"270984d03e94bb8b"}]}],"schemaUrl":"https://opentelemetry.io/schemas/1.24.0"}]}
```

<!-- prettier-ignore-end -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This JSON output is unreadable. Let Prettier format it, or format it manually. If it is too big, then wrap it in a <details> element.

traces and metrics.

Any feedback or questions? Reach out on
[GitHub](https://github.com/open-telemetry/opentelemetry-specification/pull/4183).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this linking to a spec PR?
Is this PR really the best place for folks to comment?
If so, that's ok, but then the link text should explain more clearly what the link target is.

@chalin
Copy link
Contributor

chalin commented Nov 20, 2024

/fix:refcache

@opentelemetrybot
Copy link
Collaborator

You triggered fix:refcache action run at https://github.com/open-telemetry/opentelemetry.io/actions/runs/11931927870

@opentelemetrybot
Copy link
Collaborator

fix:refcache was successful.

IMPORTANT: (RE-)RUN /fix:all to ensure that there are no remaining check issues.

@opentelemetrybot opentelemetrybot requested a review from a team November 20, 2024 12:55
Copy link
Contributor

@tiffany76 tiffany76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, subject to @chalin's comments.

cyrille-leclerc and others added 21 commits November 21, 2024 10:45
Co-authored-by: Severin Neumann <[email protected]>
Co-authored-by: Tiffany Hrabusa <[email protected]>
@chalin
Copy link
Contributor

chalin commented Nov 21, 2024

/fix:format

@opentelemetrybot
Copy link
Collaborator

You triggered fix:format action run at https://github.com/open-telemetry/opentelemetry.io/actions/runs/11956865359

@opentelemetrybot
Copy link
Collaborator

fix:format was successful.

IMPORTANT: (RE-)RUN /fix:all to ensure that there are no remaining check issues.

@opentelemetrybot opentelemetrybot requested a review from a team November 21, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

6 participants