Skip to content

OTel logs should go through SdkLogger not direct to log processor - #3807

Draft
itowlson wants to merge 1 commit into
spinframework:mainfrom
itowlson:dammit-otel
Draft

itowlson wants to merge 1 commit into
spinframework:mainfrom
itowlson:dammit-otel

Conversation

@itowlson

Copy link
Copy Markdown
Contributor

It looks like we should not be calling the LogProcessor directly, but instead interposing a SdkLogger. This is needed because OTel packs an absolutely massive tanty if a log doesn't have an observed timestamp, and SdkLogger adds one if it's missing. (You are correct. This is indeed suboptimal.)

Draft because:

  1. I have no idea how all the OTel bits fit together so this is kind of "hit the compiler with a shoe until it lets me do the thing"
  2. I am not sure how to test it
  3. We really want to move to a more recent version of OTel anyway, which will presumably have excitingly different suboptimalities
  4. If we do use it then they'll probably want me to rename some things, you know what they're like

cc @asteurer who I think is also familiar with the OTel factor, is that right Andrew?

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@asteurer

Copy link
Copy Markdown
Contributor

Yeah, I did some work on the OTel factor stuff; however, I won't be able to spare the cycles to help out with this 😞. Maybe @calebschoepp can offer some insight? He and I worked on wasi-otel together.

@calebschoepp calebschoepp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding testing I don't recall what we have in repo for tests around wasi-otel. If there is nothing then just ship it I guess.

One thing you could do is point an agent at the integration tests in https://github.com/bytecodealliance/opentelemetry-wasi and pin it to this version of Spin to confirm it still works.

let (mut record, scope) = spin_world::wasi_otel::parse_wasi_log_record(data);
log_processor.emit(&mut record, &scope);
let (record, scope) = spin_world::wasi_otel::parse_wasi_log_record(data);
let log_processor = sdk_log_provider.logger_with_scope(scope);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let log_processor = sdk_log_provider.logger_with_scope(scope);
let logger = sdk_log_provider.logger_with_scope(scope);

The logger is something that feeds into the log processor.


// OTel is mad about our Arc. Dammit OTel
#[derive(Debug)]
struct DammitOTel(Arc<BatchLogProcessor<Tokio>>);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Not quite enough condemnation for my taste

}

let sdk_logger_provider = self.log_processor.as_ref().map(|lp| {
let log_processor = DammitOTel(lp.clone());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this just be done inline? If you purposely did this hear according to your stylistic sense that is fine too.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

3 participants