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

[WIP] Code Generation with Weaver - Example of Code Generation for SemConv Attribute Registry and SemConv Metrics #136

Merged
merged 47 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
328a89f
feat(codegen): create an example of codegen for SemConv Rust
lquerel Apr 26, 2024
d430eb6
feat(codegen): create lib.rs and one rs file per group prefix
lquerel Apr 26, 2024
35959a7
feat(codegen): remove old tera templates
lquerel Apr 26, 2024
618b8d2
feat(codegen): add support for semconv_experimental feature
lquerel Apr 26, 2024
db4dec4
chore: bump minijinja version to 1.0.21
lquerel Apr 27, 2024
d404191
chore: Fix fmt and clippy issues
lquerel Apr 27, 2024
628d46e
feat(forge): Add type_mapping filter
lquerel Apr 28, 2024
65c2464
doc(forge): Update documentation
lquerel Apr 28, 2024
7d26226
chore(forge): Improve test coverage
lquerel Apr 28, 2024
c821e55
feat(forge): Improve SemConv codegen example for Rust
lquerel Apr 29, 2024
00e11d2
chore(forge): Add mini registry and prepare for unit tests
lquerel Apr 29, 2024
37acc4b
chore(forge): Simplify mini_registry
lquerel Apr 29, 2024
074fe69
doc(forge): Add documentation on the JQ filter.
lquerel Apr 29, 2024
f930e80
chore(forge): Fix clippy issue
lquerel Apr 30, 2024
d65680c
Merge branch 'main' into example-codegen-semconv-rust
lquerel Apr 30, 2024
30876fc
chore(forge): Add experimental and deprecated attributes in the gener…
lquerel Apr 30, 2024
9483d63
feat(forge): Add enum string representation support.
lquerel Apr 30, 2024
e2e2df1
feat(forge): Use attribute registry namespace instead of group prefix.
lquerel Apr 30, 2024
8f6826b
feat(forge): Generate metrics and attributes
lquerel May 1, 2024
48403fc
feat(forge): Generate type-safe API for metrics
lquerel May 2, 2024
5fc3248
Merge branch 'main' into example-codegen-semconv-rust
lquerel May 2, 2024
ecbd76d
feat(forge): Separate required from optional attributes in the genera…
lquerel May 2, 2024
34db6ad
feat(forge): Improve metrics type-safe API
lquerel May 3, 2024
405331f
Merge branch 'main' into example-codegen-semconv-rust
lquerel May 3, 2024
581c08c
feat(forge): Add support for Counter and Gauge
lquerel May 3, 2024
0832fb2
feat(forge): Update generated code
lquerel May 3, 2024
5d8bf55
feat(forge): Update documentation
lquerel May 3, 2024
064e844
feat(forge): Fix Clippy lint issues
lquerel May 4, 2024
3f2e188
chore(forge): Exclude generated file from code coverage
lquerel May 4, 2024
3b26644
Merge branch 'main' into example-codegen-semconv-rust
lquerel May 4, 2024
7ec190d
chore(forge): Test infra for code gen [WIP]
lquerel May 4, 2024
da441c3
chore(forge): Remove build.rs
lquerel May 5, 2024
7ee2235
Merge branch 'main' into example-codegen-semconv-rust
lquerel May 6, 2024
c006d17
chore(forge): Move to not_required filter
lquerel May 6, 2024
8757379
Merge remote-tracking branch 'origin/example-codegen-semconv-rust' in…
lquerel May 6, 2024
97ee4a3
chore(forge): Improve error messages
lquerel May 6, 2024
9045e05
chore(forge): Create code generation test infrastructure
lquerel May 7, 2024
423111b
chore(forge): Create code generation test infrastructure
lquerel May 7, 2024
1306e6a
chore(forge): Create code generation test infrastructure
lquerel May 7, 2024
19e07c2
chore(forge): Remove duplicated codes and semconv registry
lquerel May 7, 2024
3534c42
chore(forge): Fix Windows specific issue.
lquerel May 7, 2024
964a5cb
Merge branch 'main' into example-codegen-semconv-rust
lquerel May 7, 2024
b858e7c
chore(forge): Improve error message to debug Windows specific issue.
lquerel May 7, 2024
c0aea47
Merge remote-tracking branch 'origin/example-codegen-semconv-rust' in…
lquerel May 7, 2024
baa9e2a
chore(forge): Add traces to debug Windows specific issue.
lquerel May 7, 2024
2f2ce45
chore(forge): Fix MiniJinja template loader for Windows.
lquerel May 8, 2024
dd0dc61
chore(forge): Fix MiniJinja template loader for Windows.
lquerel May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ coverage:

ignore:
- "crates/xtask" # Part of the build system
- "src" # CLI (not tested yet)
- "src" # CLI (not tested yet)
- "crates/weaver_forge/codegen_examples/expected_codegen" # Generated code
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Gather coverage
run: cargo tarpaulin --workspace --output-dir coverage --out lcov -e xtask -e weaver
run: cargo tarpaulin --workspace --output-dir coverage --out lcov -e xtask -e weaver --exclude-files 'crates/weaver_forge/codegen_examples/expected_codegen/*'
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
Expand Down
152 changes: 127 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ categories = ["command-line-utilities"]
license = "Apache-2.0"
readme = "README.md"
publish = false
resolver = "2"

# Workspace definition ========================================================
[workspace]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![build](https://github.com/open-telemetry/weaver/actions/workflows/audit.yml/badge.svg)](https://github.com/open-telemetry/weaver/actions/workflows/audit.yml)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
----
(CONTRIBUTING.md) | [Links](#links) |

[Getting started](#getting-started) | [Main commands](#main-commands) | [Generate Doc & Code](crates/weaver_forge/README.md) | [Architecture](docs/architecture.md) | [Change log](CHANGELOG.md) | [Contributing](CONTRIBUTING.md) | [Links](#links) |

## What is OpenTelemetry Weaver?
Expand Down
23 changes: 23 additions & 0 deletions crates/weaver_codegen_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "weaver_codegen_test"
version = "0.1.0"
authors.workspace = true
repository.workspace = true
license.workspace = true
publish.workspace = true
edition.workspace = true
rust-version.workspace = true

[lints]
workspace = true

[build-dependencies]
weaver_common = { path = "../weaver_common" }
weaver_cache = { path = "../weaver_cache" }
weaver_forge = { path = "../weaver_forge" }
weaver_resolver = { path = "../weaver_resolver" }
weaver_semconv = { path = "../weaver_semconv" }
walkdir.workspace = true

[dependencies]
opentelemetry = { version = "0.22.0", features = ["trace", "metrics", "logs", "otel_unstable"] }
7 changes: 7 additions & 0 deletions crates/weaver_codegen_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Weaver CodeGen Test

This crate is used to test the generation of an unofficial Rust OpenTelemetry Client API derived from a semantic
convention registry. This crate is not intended to be published. It is used solely for testing and validation purposes.

The generated Rust API client exposes a type-safe API (i.e., one that cannot be misused) that adheres to the signal
specification defined in the semantic convention registry located in the semconv_registry directory.
6 changes: 6 additions & 0 deletions crates/weaver_codegen_test/allowed-external-types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# This is used with cargo-check-external-types to reduce the surface area of downstream crates from
# the public API. Ideally this can have a few exceptions as possible.
allowed_external_types = [
]
Loading
Loading