Skip to content

Conversation

@jeremycline
Copy link
Member

While debugging why running azure-init in a local VM hung forever, I added some minimal log configuration to figure out what was happening. Note that this only logs to stderr and is only configurable via the AZURE_INIT_LOG environment variable. The most minimal usage is like this:

AZURE_INIT_LOG=info azure-init

Which emits anything at info level or high. Refer to the tracing-subscriber documentation[0] for more complex examples.

Logs look like this:

2024-07-16T14:41:16.924909Z  INFO provision: azure_init: new
2024-07-16T14:41:16.928668Z  INFO provision:get_environment: azure_init: new
...
2024-07-16T14:41:17.065528Z  INFO provision:get_environment: azure_init: close time.busy=133ms time.idle=4.21ms
2024-07-16T14:41:17.073142Z  INFO provision:get_username: azure_init: new
2024-07-16T14:41:17.076323Z  INFO provision:get_username: azure_init: close time.busy=23.3µs time.idle=3.16ms
2024-07-16T14:41:17.081070Z  INFO provision: azure_init: close time.busy=153ms time.idle=3.12ms

It's configured to emit logs when a span opens and closes in addition to any explicit tracing::{debug,info,warn,error}! call, although we can disable that if folks don't like it. I also added spans to most of the library functions. All the spans are at the default INFO level and the default log configuration is to write logs for warning or higher, so running this without specifying AZURE_INIT_LOG results in the same behavior as before.

This doesn't try to integrate with OpenTelemetry or pipe logs to KVP; those are being wired up in #83.

[0] https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/filter/struct.EnvFilter.html#directives

While debugging why running azure-init in a local VM hung forever, I
added some minimal log configuration to figure out what was happening.
Note that this only logs to stderr and is only configurable via the
`AZURE_INIT_LOG` environment variable. The most minimal usage is like
this:

AZURE_INIT_LOG=info azure-init

Which emits anything at info level or high. Refer to the
tracing-subscriber documentation[0] for more complex examples.

Logs look like this:
```
2024-07-16T14:41:16.924909Z  INFO provision: azure_init: new
2024-07-16T14:41:16.928668Z  INFO provision:get_environment: azure_init: new
...
2024-07-16T14:41:17.065528Z  INFO provision:get_environment: azure_init: close time.busy=133ms time.idle=4.21ms
2024-07-16T14:41:17.073142Z  INFO provision:get_username: azure_init: new
2024-07-16T14:41:17.076323Z  INFO provision:get_username: azure_init: close time.busy=23.3µs time.idle=3.16ms
2024-07-16T14:41:17.081070Z  INFO provision: azure_init: close time.busy=153ms time.idle=3.12ms
```

It's configured to emit logs when a span opens and closes in addition to
any explicit `tracing::{debug,info,warn,error}!` call, although we can
disable that if folks don't like it. I also added spans to most of the
library functions. All the spans are at the default `INFO` level and the
default log configuration is to write logs for warning or higher, so
running this without specifying `AZURE_INIT_LOG` results in the same
behavior as before.

This doesn't try to integrate with OpenTelemetry or pipe logs to KVP;
those are being wired up in Azure#83.

[0] https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/filter/struct.EnvFilter.html#directives
Copy link
Contributor

@peytonr18 peytonr18 left a comment

Choose a reason for hiding this comment

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

LGTM! Shouldn't be hard to rebase the KVP with this.

@dongsupark dongsupark merged commit 7142bce into Azure:main Jul 16, 2024
@jeremycline jeremycline deleted the minimal-tracing-conf branch July 16, 2024 18:13
balakreddy pushed a commit to balakreddy/azure-init that referenced this pull request Jul 19, 2024
While debugging why running azure-init in a local VM hung forever, I
added some minimal log configuration to figure out what was happening.
Note that this only logs to stderr and is only configurable via the
`AZURE_INIT_LOG` environment variable. The most minimal usage is like
this:

AZURE_INIT_LOG=info azure-init

Which emits anything at info level or high. Refer to the
tracing-subscriber documentation[0] for more complex examples.

Logs look like this:
```
2024-07-16T14:41:16.924909Z  INFO provision: azure_init: new
2024-07-16T14:41:16.928668Z  INFO provision:get_environment: azure_init: new
...
2024-07-16T14:41:17.065528Z  INFO provision:get_environment: azure_init: close time.busy=133ms time.idle=4.21ms
2024-07-16T14:41:17.073142Z  INFO provision:get_username: azure_init: new
2024-07-16T14:41:17.076323Z  INFO provision:get_username: azure_init: close time.busy=23.3µs time.idle=3.16ms
2024-07-16T14:41:17.081070Z  INFO provision: azure_init: close time.busy=153ms time.idle=3.12ms
```

It's configured to emit logs when a span opens and closes in addition to
any explicit `tracing::{debug,info,warn,error}!` call, although we can
disable that if folks don't like it. I also added spans to most of the
library functions. All the spans are at the default `INFO` level and the
default log configuration is to write logs for warning or higher, so
running this without specifying `AZURE_INIT_LOG` results in the same
behavior as before.

This doesn't try to integrate with OpenTelemetry or pipe logs to KVP;
those are being wired up in Azure#83.

[0] https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/filter/struct.EnvFilter.html#directives
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