Skip to content

Getting Started with OpenTelemetry Rust Logs in 5 Minutes - Exporting logs to user_events#2

Open
lalitb wants to merge 20 commits into
mainfrom
user-events-doc
Open

Getting Started with OpenTelemetry Rust Logs in 5 Minutes - Exporting logs to user_events#2
lalitb wants to merge 20 commits into
mainfrom
user-events-doc

Conversation

@lalitb

@lalitb lalitb commented Sep 6, 2023

Copy link
Copy Markdown
Owner

Fixes #
Design discussion issue (if applicable) #

Changes

Please provide a brief description of the changes here.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

Comment thread opentelemetry-user-events-logs/examples/README.md Outdated

### How to configure:

1. Create ExporterConfig with below settings:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think 2,3 here are irrelevant, and we should hide it from users.

@lalitb lalitb Sep 6, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

step 2 is setting up the provider_name. Will remove step 3.

Or do you mean to add wrapper on top of these APIs to hide from users ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yes. but it can be done later.
something like loggerProviderBuilder.add_user_event_exporter(provider_name)

Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
Comment thread opentelemetry-user-events-logs/examples/README.md
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
Comment thread opentelemetry-user-events-logs/examples/README.md
Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
Comment thread opentelemetry-user-events-logs/examples/README.md
Comment thread opentelemetry-user-events-logs/examples/basic.rs Outdated
Comment thread opentelemetry-user-events-logs/examples/README.md Outdated

2. Create LogProcessor instance:
```rust
let processor = ReentrantLogProcessor::new("test_provider", None, exporter_config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Curious - what's the semantic of the first parameter?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It's documented here - https://github.com/microsoft/LinuxTracepoints/tree/main/libeventheader-tracepoint#provider-names :

--clip
A provider is a component that generates events. Each event from a provider is associated with a Provider Name that uniquely identifies the provider.

The provider name should be short, yet descriptive enough to minimize the chance of collision and to help developers track down the component generating the events. Hierarchical namespaces may be useful for provider names, e.g. MyCompany_MyOrg_MyComponent.
-clap

Have added the link in this document.

@lalitb lalitb Sep 6, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

So a Provider can generate different unique events. In future, we can have each event mapped to a unique EventKeyword. And the combination of ProviderName + EventKeyword + Level represents a tracepoint name.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't understand why a LinuxTracepoint provider has something to do with a ReentrantLogProcessor. If you look at the name of ReentrantLogProcessor, it has nothing to do with provider.

@lalitb lalitb Sep 7, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes, the plan is to move the provider into ExporterConfig for the next release.

Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
* Rust and Cargo: [Install](https://doc.rust-lang.org/cargo/getting-started/installation.html) them if you haven't.
* A Linux system with [user_events](https://docs.kernel.org/trace/user_events.html) enabled: Ubuntu 23.10 (once available), or kernel 6.4 or later build with user_events support.
* Correct Permissions: Linux user(preferable non-root) with write permission to the tracefs.
* A listener/agent to listen for new events. Or else [perf](https://perf.wiki.kernel.org/index.php/Main_Page) and [decode-perf](https://github.com/microsoft/LinuxTracepoints/tree/main/libeventheader-decode-cpp/tools) tools installed for validation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does "or else" mean?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since this is more of a getting-started example, we don't have to list all possible ways, I suggest that we just provide the most common way or an easy way (e.g. download XYZ tool and use that).

@lalitb lalitb Sep 7, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Good point. Only using the perf/decode-perf tool now.

event_id = 20,
user_name = "otel user",
user_email = "otel@opentelemetry.io"
//event_name = "my-event-name",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@cijothomas what's the expected way (end goal) of specifying event name?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It is supposed to be error!( name: "myevent", ...) ref - https://github.com/tokio-rs/tracing/blob/b8c45ccd067a6aebdd9257c5edda6bc90bcf9028/tracing/src/lib.rs#L247

Have updated the example accordingly. Thanks for pointing out.


The example code uses `test` as the ProviderName and `1` as the EventKeyword. So, it makes these 5 tracepoints:

* test_L5K1Gtest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This needs to be updated to reflect the provider name change?

Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
lalitb and others added 2 commits September 6, 2023 23:05
Co-authored-by: Reiley Yang <reyang@microsoft.com>
Comment thread opentelemetry-user-events-logs/examples/README.md Outdated
Comment thread opentelemetry-user-events-logs/examples/basic.rs Outdated
### What you need to know:

* [ProviderName](https://github.com/microsoft/LinuxTracepoints/tree/main/libeventheader-tracepoint#provider-names) and [EventKeyword](https://github.com/microsoft/LinuxTracepoints/tree/main/libeventheader-tracepoint#tracepoint-names) can be changed using Exporter configuration.
* `ProviderGroup` is assigned the value of `ProviderName`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does the user need to know this?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I thought it is good for them to know that ProviderGroupis not configurable, and also make them understand why myprovider comes twice in tracepoint name myprovider_L5K1Gmyprovider

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Got it.! Yea it can be confusing without this to see myprovider twice.

$ perf record -e user_events:myprovider_L2K1Gmyprovider
<ctrl-c after running example code>
$ decode-perf ./perf.data
<log data is output here>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you paste an actual output, so it is easy to compare where things land?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Sure, added now.

lalitb and others added 2 commits September 7, 2023 10:22
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience.

It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open.

@github-actions github-actions Bot added the Stale label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants