Skip to content

Commit

Permalink
Merge pull request #43 from lquerel/minijinja
Browse files Browse the repository at this point in the history
Generate assets from a semantic convention registry and a set of jinja2 templates
  • Loading branch information
lquerel authored Mar 8, 2024
2 parents 8293ebb + 935aed1 commit 7b75f3c
Show file tree
Hide file tree
Showing 154 changed files with 28,467 additions and 5,310 deletions.
288 changes: 160 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ureq = "2.9.6"
regex = "1.10.3"
rayon = "1.8.1"
ordered-float = { version = "4.2.0", features = ["serde"] }
walkdir = "2.5.0"

# Features definition =========================================================
[features]
Expand All @@ -53,7 +54,7 @@ weaver_semconv = { path = "crates/weaver_semconv" }
weaver_schema = { path = "crates/weaver_schema" }
weaver_cache = { path = "crates/weaver_cache" }

clap = { version = "4.5.1", features = ["derive"] }
clap = { version = "4.5.2", features = ["derive"] }
crossterm = "0.27.0"
ratatui = "0.26.1"
tui-textarea = "0.4.0"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Below is a diagram detailing the primary components of the OpenTelemetry Weaver
## Links

Internal links:
- [Template Engine](docs/template-engine.md)
- [Component Telemetry Schema](docs/component-telemetry-schema.md) (proposal)
- [Resolved Telemetry Schema](docs/resolved-telemetry-schema.md) (proposal)
- [Internal crates interdependencies](docs/dependencies.md)
Expand Down
26 changes: 26 additions & 0 deletions crates/weaver_forge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "weaver_forge"
version = "0.1.0"
authors.workspace = true
repository.workspace = true
license.workspace = true
publish.workspace = true
edition.workspace = true

[dependencies]
weaver_logger = { path = "../weaver_logger" }
weaver_resolver = { path = "../weaver_resolver" }
weaver_resolved_schema = { path = "../weaver_resolved_schema" }
weaver_semconv = { path = "../weaver_semconv" }

minijinja = { version = "1.0.12", features = ["loader", "custom_syntax"] }
convert_case = "0.6.0"
glob = "0.3.1"

thiserror.workspace = true
serde.workspace = true
serde_yaml.workspace = true
serde_json.workspace = true
rayon.workspace = true
walkdir.workspace = true

6 changes: 6 additions & 0 deletions crates/weaver_forge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Template Engine

Status: **Work-In-Progress**

This crate extends the `MiniJinja` template engine with custom filters and
functions.
10 changes: 10 additions & 0 deletions crates/weaver_forge/allowed-external-types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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 = [
"serde::ser::Serialize",
"serde::de::Deserialize",
"weaver_logger::*",
"weaver_resolved_schema::*",
]
32 changes: 32 additions & 0 deletions crates/weaver_forge/data/exporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
groups:
- id: otel.scope
prefix: otel.scope
type: resource
brief: Attributes used by non-OTLP exporters to represent OpenTelemetry Scope's concepts.
attributes:
- id: name
type: string
brief: The name of the instrumentation scope - (`InstrumentationScope.Name` in OTLP).
examples: ['io.opentelemetry.contrib.mongodb']
stability: stable
- id: version
type: string
brief: The version of the instrumentation scope - (`InstrumentationScope.Version` in OTLP).
examples: ['1.0.0']
stability: stable
- id: otel.library
prefix: otel.library
type: resource
brief: >
Span attributes used by non-OTLP exporters to represent OpenTelemetry Scope's concepts.
attributes:
- id: name
type: string
deprecated: use the `otel.scope.name` attribute.
brief:
examples: ['io.opentelemetry.contrib.mongodb']
- id: version
type: string
deprecated: use the `otel.scope.version` attribute.
brief:
examples: ['1.0.0']
186 changes: 186 additions & 0 deletions crates/weaver_forge/data/jvm-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
groups:
- id: attributes.jvm.memory
type: attribute_group
brief: "Describes JVM memory metric attributes."
prefix: jvm.memory
attributes:
- id: type
stability: stable
type:
allow_custom_values: false
members:
- id: heap
value: 'heap'
brief: 'Heap memory.'
- id: non_heap
value: 'non_heap'
brief: 'Non-heap memory'
requirement_level: recommended
brief: The type of memory.
examples: ["heap", "non_heap"]
- id: pool.name
stability: stable
type: string
requirement_level: recommended
brief: Name of the memory pool.
examples: ["G1 Old Gen", "G1 Eden space", "G1 Survivor Space"]
note: >
Pool names are generally obtained via
[MemoryPoolMXBean#getName()](https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()).
- id: metric.jvm.memory.used
type: metric
metric_name: jvm.memory.used
extends: attributes.jvm.memory
brief: "Measure of memory used."
instrument: updowncounter
unit: "By"
stability: stable

- id: metric.jvm.memory.committed
type: metric
metric_name: jvm.memory.committed
extends: attributes.jvm.memory
brief: "Measure of memory committed."
instrument: updowncounter
unit: "By"
stability: stable

- id: metric.jvm.memory.limit
type: metric
metric_name: jvm.memory.limit
extends: attributes.jvm.memory
brief: "Measure of max obtainable memory."
instrument: updowncounter
unit: "By"
stability: stable

- id: metric.jvm.memory.used_after_last_gc
type: metric
metric_name: jvm.memory.used_after_last_gc
extends: attributes.jvm.memory
brief: "Measure of memory used, as measured after the most recent garbage collection event on this pool."
instrument: updowncounter
unit: "By"
stability: stable

- id: metric.jvm.gc.duration
type: metric
metric_name: jvm.gc.duration
brief: "Duration of JVM garbage collection actions."
instrument: histogram
unit: "s"
prefix: jvm.gc
attributes:
- id: name
stability: stable
type: string
requirement_level: recommended
brief: Name of the garbage collector.
examples: ["G1 Young Generation", "G1 Old Generation"]
note: >
Garbage collector name is generally obtained via
[GarbageCollectionNotificationInfo#getGcName()](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcName()).
- id: action
stability: stable
type: string
requirement_level: recommended
brief: Name of the garbage collector action.
examples: ["end of minor GC", "end of major GC"]
note: >
Garbage collector action is generally obtained via
[GarbageCollectionNotificationInfo#getGcAction()](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcAction()).
stability: stable

- id: metric.jvm.thread.count
type: metric
metric_name: jvm.thread.count
brief: "Number of executing platform threads."
instrument: updowncounter
unit: "{thread}"
attributes:
- id: jvm.thread.daemon
stability: stable
type: boolean
requirement_level: recommended
brief: "Whether the thread is daemon or not."
- id: jvm.thread.state
stability: stable
requirement_level: recommended
type:
allow_custom_values: false
members:
- id: new
value: 'new'
brief: 'A thread that has not yet started is in this state.'
- id: runnable
value: 'runnable'
brief: 'A thread executing in the Java virtual machine is in this state.'
- id: blocked
value: 'blocked'
brief: 'A thread that is blocked waiting for a monitor lock is in this state.'
- id: waiting
value: 'waiting'
brief: 'A thread that is waiting indefinitely for another thread to perform a particular action is in this state.'
- id: timed_waiting
value: 'timed_waiting'
brief: 'A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.'
- id: terminated
value: 'terminated'
brief: 'A thread that has exited is in this state.'
brief: "State of the thread."
examples: ["runnable", "blocked"]
stability: stable

- id: metric.jvm.class.loaded
type: metric
metric_name: jvm.class.loaded
brief: "Number of classes loaded since JVM start."
instrument: counter
unit: "{class}"
stability: stable

- id: metric.jvm.class.unloaded
type: metric
metric_name: jvm.class.unloaded
brief: "Number of classes unloaded since JVM start."
instrument: counter
unit: "{class}"
stability: stable

- id: metric.jvm.class.count
type: metric
metric_name: jvm.class.count
brief: "Number of classes currently loaded."
instrument: updowncounter
unit: "{class}"
stability: stable

- id: metric.jvm.cpu.count
type: metric
metric_name: jvm.cpu.count
brief: "Number of processors available to the Java virtual machine."
instrument: updowncounter
unit: "{cpu}"
stability: stable

- id: metric.jvm.cpu.time
type: metric
metric_name: jvm.cpu.time
brief: "CPU time used by the process as reported by the JVM."
instrument: counter
unit: "s"
stability: stable

- id: metric.jvm.cpu.recent_utilization
type: metric
metric_name: jvm.cpu.recent_utilization
brief: "Recent CPU utilization for the process as reported by the JVM."
note: >
The value range is [0.0,1.0].
This utilization is not defined as being for the specific interval since last measurement
(unlike `system.cpu.utilization`).
[Reference](https://docs.oracle.com/en/java/javase/17/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getProcessCpuLoad()).
instrument: gauge
unit: "1"
stability: stable
74 changes: 74 additions & 0 deletions crates/weaver_forge/data/mobile-events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
groups:
- id: ios.lifecycle.events
type: event
prefix: ios
name: device.app.lifecycle
brief: >
This event represents an occurrence of a lifecycle transition on the iOS platform.
attributes:
- id: state
stability: experimental
requirement_level: "required"
note: >
The iOS lifecycle states are defined in the [UIApplicationDelegate documentation](https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902),
and from which the `OS terminology` column values are derived.
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
type:
allow_custom_values: false
members:
- id: active
value: 'active'
brief: >
The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`.
- id: inactive
value: 'inactive'
brief: >
The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`.
- id: background
value: 'background'
brief: >
The app is now in the background.
This value is associated with UIKit notification `applicationDidEnterBackground`.
- id: foreground
value: 'foreground'
brief: >
The app is now in the foreground.
This value is associated with UIKit notification `applicationWillEnterForeground`.
- id: terminate
value: 'terminate'
brief: >
The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`.
- id: android.lifecycle.events
type: event
prefix: android
name: device.app.lifecycle
brief: >
This event represents an occurrence of a lifecycle transition on the Android platform.
attributes:
- id: state
stability: experimental
requirement_level: required
brief: >
This attribute represents the state the application has transitioned into at the occurrence of the event.
note: >
The Android lifecycle states are defined in [Activity lifecycle callbacks](https://developer.android.com/guide/components/activities/activity-lifecycle#lc),
and from which the `OS identifiers` are derived.
type:
allow_custom_values: false
members:
- id: created
value: 'created'
brief: >
Any time before Activity.onResume() or, if the app has no Activity, Context.startService()
has been called in the app for the first time.
- id: background
value: 'background'
brief: >
Any time after Activity.onPause() or, if the app has no Activity,
Context.stopService() has been called when the app was in the foreground state.
- id: foreground
value: 'foreground'
brief: >
Any time after Activity.onResume() or, if the app has no Activity,
Context.startService() has been called when the app was in either the created or background states.
Loading

0 comments on commit 7b75f3c

Please sign in to comment.