封装参考
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.4.0-beta.2" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.2.0-rc5"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.8" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.8" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.8" />
Run Code Online (Sandbox Code Playgroud)
程序.cs
builder.Services.AddOpenTelemetryMetrics(b =>
{
b.AddPrometheusExporter();
b.AddMeter(TelemetryConstants.MyAppSource);
b.SetResourceBuilder(resource);
b.AddHttpClientInstrumentation();
b.AddAspNetCoreInstrumentation();
});
Run Code Online (Sandbox Code Playgroud)
当我运行该应用程序时,出现以下错误
System.TypeLoadException: 'Could not load type 'System.ServiceProviderExtensions' from assembly 'OpenTelemetry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c'.'
在app.UseOpenTelemetryPrometheusScrapingEndpoint();
我有组件 A、组件 B 和一项服务。我在服务中声明了 Subject 并订阅了组件 B. 中的主题,并且在导航到组件 B 之前,我将一些数据从组件 A 发送到主题。它正在导航到组件 B,但没有触发订阅方法。
服务:
@Injectable({
providedIn: 'root'
})
export class ServiceTestService {
storage: Recipe;
recipeSelected = new Subject<any>();
constructor() { }
}
Run Code Online (Sandbox Code Playgroud)
组件 A向 observable 发送消息
@Component({
selector: 'app-recipe-item',
templateUrl: './recipe-item.component.html'
})
export class RecipeItemComponent implements OnInit {
@Input() recipe: Recipe;
constructor(
private recipeService: ServiceTestService,
private rt: Router) { }
ngOnInit() {
}
onRecipeSelected(name: number) {
this.recipeService.recipeSelected.next(this.recipe);
this.rt.navigate(['/recipe', this.ind]);
}
}
Run Code Online (Sandbox Code Playgroud)
组件 B: 这里我订阅了 Observable。
@Component({
selector: 'app-recipe-detail',
templateUrl: …Run Code Online (Sandbox Code Playgroud)