Skip to content

Commit f396d4e

Browse files
Enable deterministic builds (#142)
1 parent 1b046a7 commit f396d4e

File tree

10 files changed

+242
-105
lines changed

10 files changed

+242
-105
lines changed

.github/workflows/ci.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- '**.md'
8+
pull_request:
9+
branches: [ main ]
10+
workflow_dispatch:
11+
12+
env:
13+
DOTNET_CLI_TELEMETRY_OPTOUT: true
14+
DOTNET_NOLOGO: true
15+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
16+
NUGET_XMLDOC_MODE: skip
17+
TERM: xterm
18+
19+
permissions: {}
20+
21+
jobs:
22+
build-test:
23+
name: ${{ matrix.os-name }}
24+
runs-on: ${{ matrix.runner }}
25+
26+
outputs:
27+
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}
28+
29+
permissions:
30+
attestations: write
31+
contents: write
32+
id-token: write
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
include:
38+
- os-name: macos
39+
runner: macos-latest
40+
- os-name: linux
41+
runner: ubuntu-latest
42+
- os-name: windows
43+
runner: windows-latest
44+
45+
steps:
46+
47+
- name: Checkout code
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with:
50+
fetch-depth: 0
51+
filter: 'tree:0'
52+
show-progress: false
53+
54+
- name: Setup .NET SDK
55+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
56+
id: setup-dotnet
57+
58+
- name: Build
59+
run: dotnet build --configuration Release
60+
61+
- name: Test
62+
run: dotnet test --configuration Release --logger:"GitHubActions;report-warnings=false"
63+
64+
- name: Generate SBOM
65+
uses: anchore/sbom-action@9f7302141466aa6482940f15371237e9d9f4c34a # v0.19.0
66+
with:
67+
artifact-name: build-${{ matrix.os-name }}.spdx.json
68+
output-file: ./artifacts/build.spdx.json
69+
path: ./artifacts/bin
70+
upload-release-assets: ${{ runner.os == 'Windows' }}
71+
72+
- name: Attest artifacts
73+
uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0
74+
if: |
75+
runner.os == 'Windows' &&
76+
github.event.repository.fork == false &&
77+
(github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/'))
78+
with:
79+
subject-path: |
80+
./artifacts/bin/Grafana.OpenTelemetry*/release*/Grafana.OpenTelemetry*.dll
81+
./artifacts/package/release/*
82+
83+
- name: Publish NuGet packages
84+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
85+
with:
86+
name: packages-${{ matrix.os-name }}
87+
path: ./artifacts/package/release
88+
if-no-files-found: error
89+
90+
validate-packages:
91+
needs: build-test
92+
runs-on: ubuntu-latest
93+
steps:
94+
95+
- name: Download packages
96+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
97+
with:
98+
name: packages-windows
99+
100+
- name: Setup .NET SDK
101+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
102+
with:
103+
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }}
104+
105+
- name: Validate NuGet packages
106+
shell: pwsh
107+
run: |
108+
dotnet tool install --global dotnet-validate --version 0.0.1-preview.304 --allow-roll-forward
109+
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
110+
$invalidPackages = 0
111+
foreach ($package in $packages) {
112+
dotnet validate package local $package
113+
if ($LASTEXITCODE -ne 0) {
114+
$invalidPackages++
115+
}
116+
}
117+
if ($invalidPackages -gt 0) {
118+
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
119+
exit 1
120+
}

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
mono_crash.*
1818

1919
# Build results
20+
[Aa]rtifacts/
2021
[Bb]uild/
2122
[Dd]ebug/
2223
[Dd]ebugPublic/

Directory.Build.props

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project>
2+
<PropertyGroup>
3+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
4+
<Authors>Grafana Labs</Authors>
5+
<ChecksumAlgorithm>SHA256</ChecksumAlgorithm>
6+
<Company>Grafana Labs</Company>
7+
<ContinuousIntegrationBuild Condition=" '$(CI)' != '' ">true</ContinuousIntegrationBuild>
8+
<Copyright>Copyright (c) Grafana Labs</Copyright>
9+
<Deterministic>true</Deterministic>
10+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
11+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
12+
<NeutralLanguage>en-US</NeutralLanguage>
13+
<!-- Disable warning about stable packages depending on prerelease packages until all OpenTelemetry dependencies are stable -->
14+
<NoWarn>$(NoWarn);NU5104</NoWarn>
15+
<Nullable>disable</Nullable>
16+
<PackageIcon>Grafana_icon.png</PackageIcon>
17+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
18+
<PackageProjectUrl>https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/</PackageProjectUrl>
19+
<PackageReadmeFile>package-readme.md</PackageReadmeFile>
20+
<PackageReleaseNotes>https://github.com/grafana/grafana-opentelemetry-dotnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
21+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
22+
<PackageTags>OpenTelemetry;Grafana;Metrics;Logs;Traces;Observability;Monitoring</PackageTags>
23+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
24+
<RepositoryType>git</RepositoryType>
25+
<RepositoryUrl>https://github.com/grafana/grafana-opentelemetry-dotnet</RepositoryUrl>
26+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
27+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
28+
<UseArtifactsOutput>true</UseArtifactsOutput>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<None Include="$(MSBuildThisFileDirectory)/internal/img/$(PackageIcon)" Pack="true" PackagePath="" />
32+
<None Include="$(MsBuildThisFileDirectory)/$(PackageReadmeFile)" Pack="true" PackagePath="" />
33+
</ItemGroup>
34+
</Project>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ To engage with the Grafana Application Observability community:
101101
* [File an issue][issues] for bugs, issues, and feature suggestions.
102102

103103
[app-o11y]: https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/
104-
[ci-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/unit-tests.yml/badge.svg?branch=main
105-
[ci-status]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/unit-tests.yml
104+
[ci-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/ci.yml/badge.svg?branch=main
105+
[ci-status]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/ci.yml
106106
[discussions]: https://github.com/grafana/grafana-opentelemetry-dotnet/discussions
107107
[issues]: https://github.com/grafana/grafana-opentelemetry-dotnet/issues/new
108108
[oats-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/oats.yml/badge.svg?branch=main

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
33
"rollForward": "latestFeature",
4-
"version": "8.0.101",
4+
"version": "8.0.410",
55
"allowPrerelease": false
66
}
77
}

package-readme.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Grafana OpenTelemetry distribution for .NET
2+
3+
<!-- markdown-link-check-disable -->
4+
[![NuGet][package-badge-version]][package-download]
5+
[![SDK][otel-badge]][otel]
6+
[![Slack][slack-badge]][slack-channel]
7+
<!-- markdown-link-check-enable -->
8+
9+
## About
10+
11+
This is a pre-configured and pre-packaged bundle of [OpenTelemetry .NET components][otel-contrib],
12+
optimized for [Grafana Cloud Application Observability][app-o11y].
13+
14+
It requires only minimal setup and configuration and makes it very easy to emit
15+
OpenTelemetry metrics, logs, and traces from your .NET application.
16+
17+
## Getting Started
18+
19+
### Step 1: Install package
20+
21+
For installing the distribution with the full set of dependencies, add a
22+
reference to the [`Grafana.OpenTelemetry`][package] package to your project.
23+
24+
```sh
25+
dotnet add package Grafana.OpenTelemetry
26+
```
27+
28+
### Step 2: Enable the Grafana distribution at application startup
29+
30+
The `UseGrafana` extension method on the `TracerProviderBuilder` or the
31+
`MetricProviderBuilder` can be used to set up the Grafana distribution. By
32+
default, telemetry data will be sent to Grafana Alloy or an OpenTelemetry collector
33+
that runs locally and listens to default OTLP ports.
34+
35+
```csharp
36+
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
37+
.UseGrafana()
38+
.Build();
39+
```
40+
41+
Alternatively, you can send telemetry data directly to Grafana Cloud without
42+
involving an agent or collector. This can be configured via the environment
43+
variables `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT`, and
44+
`OTEL_EXPORTER_OTLP_HEADERS`.
45+
46+
For details on how to obtain those values, refer to
47+
[Send data to the Grafana Cloud OTLP endpoint: Quickstart architecture][push-oltp].
48+
49+
## Documentation
50+
51+
For detailed documentation and setup instructions, refer to [our documentation][docs].
52+
53+
[app-o11y]: https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/
54+
[docs]: https://github.com/grafana/grafana-opentelemetry-dotnet/tree/main/docs
55+
[otel]: https://github.com/open-telemetry/opentelemetry-dotnet
56+
[otel-badge]: https://img.shields.io/badge/OTel--SDK-1.9.0-blue?style=flat&logo=opentelemetry
57+
[otel-contrib]: http://github.com/open-telemetry/opentelemetry-dotnet-contrib
58+
[package]: https://www.nuget.org/packages/Grafana.OpenTelemetry
59+
[package-badge-version]: https://img.shields.io/nuget/v/Grafana.OpenTelemetry?logo=nuget&label=NuGet&color=blue
60+
[package-download]: https://www.nuget.org/profiles/Grafana
61+
[push-oltp]: https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/#quickstart-architecture
62+
[slack-badge]: https://img.shields.io/badge/%20Slack-%23app--o11y-brightgreen.svg?logo=slack
63+
[slack-channel]: https://grafana.slack.com/archives/C05E87XRK3J
Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;netstandard2.0;net462</TargetFrameworks>
5-
<Nullable>disable</Nullable>
6-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7-
8-
<!-- NuGet packaging properties -->
94
<Description>Minimal Grafana distribution of OpenTelemetry .NET</Description>
10-
<Authors>Grafana Labs</Authors>
11-
<Copyright>Copyright (c) Grafana Labs</Copyright>
12-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
13-
<PackageTags>OpenTelemetry;Grafana;Metrics;Logs;Traces;Observability;Monitoring</PackageTags>
14-
<PackageIcon>Grafana_icon.png</PackageIcon>
15-
<PackageReleaseNotes>https://github.com/grafana/grafana-opentelemetry-dotnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
16-
<PackageProjectUrl>https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/</PackageProjectUrl>
17-
<RepositoryUrl>https://github.com/grafana/grafana-opentelemetry-dotnet</RepositoryUrl>
18-
<RepositoryType>git</RepositoryType>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<TargetFrameworks>net8.0;netstandard2.0;net462</TargetFrameworks>
197
</PropertyGroup>
208

219
<ItemGroup>
2210
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
2311
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
2412
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
2513
<PackageReference Include="System.Text.Json" Version="8.0.5" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))" />
26-
<PackageReference Include="MinVer" Version="4.3.0">
14+
<PackageReference Include="MinVer" Version="6.0.0">
2715
<PrivateAssets>all</PrivateAssets>
2816
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2917
</PackageReference>
@@ -52,18 +40,14 @@
5240
<PackageReference Include="OpenTelemetry.Resources.ProcessRuntime" Version="0.1.0-beta.2" />
5341
</ItemGroup>
5442

43+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
44+
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.0.0-beta.9" />
45+
</ItemGroup>
46+
5547
<ItemGroup>
5648
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
5749
<_Parameter1>Grafana.OpenTelemetry.Tests</_Parameter1>
5850
</AssemblyAttribute>
5951
</ItemGroup>
6052

61-
<ItemGroup>
62-
<None Include="../../internal/img/Grafana_icon.png" Pack="true" Visible="false" PackagePath="" />
63-
</ItemGroup>
64-
65-
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
66-
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.0.0-beta.9" />
67-
</ItemGroup>
68-
6953
</Project>

0 commit comments

Comments
 (0)