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

Add support for the OpenTelemetry Logging Pipeline #76

Closed
0xForerunner opened this issue Nov 9, 2023 · 7 comments
Closed

Add support for the OpenTelemetry Logging Pipeline #76

0xForerunner opened this issue Nov 9, 2023 · 7 comments

Comments

@0xForerunner
Copy link

0xForerunner commented Nov 9, 2023

How does this crate interact, if at all, with the Log Pipeline.
Any info would be of great help for me, and likely also in README.

Thanks!

@0xForerunner
Copy link
Author

Ah Okay so I now understand that tracing-log is for compatibility with the tracing-log crate. Makes sense. What I was really attempting to get at is if there is any support for the logging OpenTelemetry pipeline. I'm going to change the name of this issue to reflect that.

I'd love to see a discussion on how the logging pipeline could be implemented.

@0xForerunner 0xForerunner changed the title Add better documentation for the functionality of feature tracing-log Add support for the OpenTelemetry Logging Pipeline Nov 10, 2023
@0xForerunner
Copy link
Author

For any future people looking for the answer, opentelemetry-appender-tracing is the solution. I'm not sure why it's confusingly in a separate crate, but there it is.

@lpj145
Copy link

lpj145 commented Jan 26, 2024

The aspect of the implementation of tracing to open telemetry is so weird, omg!!! I'm really frustating with this, we can blow the entire thing and start a new good integration.

@0xForerunner
Copy link
Author

The aspect of the implementation of tracing to open telemetry is so weird, omg!!! I'm really frustating with this, we can blow the entire thing and start a new good integration.

Yeah it's all still really fresh. People are making progress though, albeit a little slower than I'd hoped. It's a big project and hard to get right.

@QAston
Copy link

QAston commented Apr 20, 2024

Does using opentelemetry-appender-tracing conflict in any way with this library?

@jssblck
Copy link

jssblck commented Apr 26, 2024

FWIW, after reading this I decided to just try it and at least in Jaeger logs are shipped as is:

fn configure_telemetry_otel(env: Environment, endpoint: &Url) -> Result<()> {
    let export_config = || ExportConfig {
        endpoint: endpoint.as_str().to_string(),
        timeout: Duration::from_secs(5),
        protocol: Protocol::Grpc,
    };
    let resources_config = || {
        Resource::new(vec![
            // https://opentelemetry.io/docs/specs/semconv/resource/
            KeyValue::new("service.name", APP_NAME),
            KeyValue::new("service.version", APP_VERSION),
            KeyValue::new("deployment.environment", env.to_string()),
        ])
    };

    let tracer = opentelemetry_otlp::new_pipeline()
        .tracing()
        .with_exporter(
            opentelemetry_otlp::new_exporter()
                .tonic()
                .with_export_config(export_config()),
        )
        .with_trace_config(
            opentelemetry_sdk::trace::config()
                .with_sampler(Sampler::AlwaysOn)
                .with_id_generator(RandomIdGenerator::default())
                .with_resource(resources_config()),
        )
        .install_batch(opentelemetry_sdk::runtime::Tokio)
        .context("install otel tracer")?;
    let metric = opentelemetry_otlp::new_pipeline()
        .metrics(opentelemetry_sdk::runtime::Tokio)
        .with_exporter(
            opentelemetry_otlp::new_exporter()
                .tonic()
                .with_export_config(export_config()),
        )
        .with_resource(resources_config())
        .with_period(Duration::from_secs(5))
        .with_timeout(Duration::from_secs(10))
        .with_aggregation_selector(DefaultAggregationSelector::new())
        .with_temporality_selector(DefaultTemporalitySelector::new())
        .build()
        .context("install otel metrics collector")?;

    let bridge_tracing = tracing_opentelemetry::layer().with_tracer(tracer);
    let bridge_metrics = tracing_opentelemetry::MetricsLayer::new(metric);

    tracing_subscriber::registry()
        .with(LevelFilter::INFO)
        // Export to the otel trace bridge
        .with(bridge_tracing)
        // Export to the otel metrics bridge
        .with(bridge_metrics)
        // Collect traces to report with errors
        .with(tracing_error::ErrorLayer::default())
        // Collect traces to export to the terminal
        .with(
            tracing_subscriber::fmt::layer()
                .pretty()
                .with_file(false)
                .with_line_number(false),
        )
        .try_init()
        .context("configure local tracing subscriber")
}

@QAston
Copy link

QAston commented Apr 26, 2024

I've tried this too, and the situation is as follows:

  • jaeger will not get events outside of spans no matter the configuration because it only supports reading tracing input
  • to get log stream output and tracing output you need both this crate and opentelemetry-appender-tracing, as they produce separate data streams (just like metrics is a separate stream from tracing), there's a small bug where appender-tracing input will not get span information [Feature]: opentelemetry-appender-tracing should respect information inside tracing::Span open-telemetry/opentelemetry-rust#1378
  • you need a service that can accept both streams like uptrace (which I use) or signoz, and configure both tracing and logger configurations to get all of the logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants