Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using FluentValidation.Results;
using SharpGrip.FluentValidation.AutoValidation.Endpoints.Results;

namespace Masa.Dcc.Service.Admin.Infrastructure;

public class CustomResultFactory : IFluentValidationAutoValidationResultFactory
Expand Down
28 changes: 18 additions & 10 deletions src/Services/Masa.Dcc.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var dbModel = JsonSerializer.Deserialize<DbModel>(connStr)!;
bool isPgsql = string.Equals(dbModel.DbType, "postgresql", StringComparison.CurrentCultureIgnoreCase);
var publicConfiguration = builder.Services.GetMasaConfiguration().ConfigurationApi.GetPublic();
StackExchangeRedisInstrumentation redisInstrumentation = default!;

var ossSptions = publicConfiguration.GetSection(DccConstants.OssKey).Get<OssOptions>()!;
builder.Services.AddObjectStorage(option => option.UseAliyunStorage(options =>
Expand All @@ -27,16 +28,23 @@
};
}));

if (!builder.Environment.IsDevelopment())
builder.Services.AddObservable(builder.Logging, new MasaObservableOptions
{
builder.Services.AddObservable(builder.Logging, () => new MasaObservableOptions
ServiceNameSpace = builder.Environment.EnvironmentName,
ServiceVersion = masaStackConfig.Version,
ServiceName = masaStackConfig.GetServiceId(MasaStackProject.DCC),
ServiceInstanceId = builder.Configuration.GetValue<string>("HOSTNAME")!
}, masaStackConfig.OtlpUrl, true, traceInstrumentConfig: traceBuilder =>
{
traceBuilder.AddRedisInstrumentation(options =>
{
ServiceNameSpace = builder.Environment.EnvironmentName,
ServiceVersion = masaStackConfig.Version,
ServiceName = masaStackConfig.GetServiceId(MasaStackProject.DCC),
ServiceInstanceId = builder.Configuration.GetValue<string>("HOSTNAME")!
}, () => masaStackConfig.OtlpUrl, true);
}
options.SetVerboseDatabaseStatements = true;
})
.ConfigureRedisInstrumentation(instrumentation =>
{
redisInstrumentation = instrumentation;
});
});

builder.Services.AddMasaIdentity(options =>
{
Expand Down Expand Up @@ -110,15 +118,15 @@

builder.Services.AddMultilevelCache(distributedCacheAction: distributedCacheOptions =>
{
distributedCacheOptions.UseStackExchangeRedisCache(redisOption);
distributedCacheOptions.UseStackExchangeRedisCache(redisOption, connectConfig: connect => redisInstrumentation.AddConnection(connect));
}, options =>
{
options.SubscribeKeyPrefix = "masa.dcc:";
options.SubscribeKeyType = SubscribeKeyType.SpecificPrefix;
});

builder.Services.AddPmClient(masaStackConfig.GetPmServiceDomain());
builder.Services.AddAuthClient(authServiceBaseAddress: masaStackConfig.GetAuthServiceDomain(), redisOption);
builder.Services.AddAuthClient(authServiceBaseAddress: masaStackConfig.GetAuthServiceDomain(), redisOption, connectConfig: connect => redisInstrumentation.AddConnection(connect));

builder.Services
#if DEBUG
Expand Down
5 changes: 4 additions & 1 deletion src/Services/Masa.Dcc.Service/_Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
global using System.Xml.Linq;
global using FluentValidation;
global using FluentValidation.Resources;
global using FluentValidation.Results;
global using Masa.BuildingBlocks.Authentication.Identity;
global using Masa.BuildingBlocks.Caching;
global using Masa.BuildingBlocks.Configuration;
Expand Down Expand Up @@ -46,9 +47,11 @@
global using Masa.Dcc.Service.Admin.Infrastructure;
global using Masa.Dcc.Service.Admin.Infrastructure.Middleware;
global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.IdentityModel.Tokens;
global using Microsoft.OpenApi.Models;
global using OpenTelemetry.Instrumentation.StackExchangeRedis;
global using OpenTelemetry.Trace;
global using SharpGrip.FluentValidation.AutoValidation.Endpoints.Extensions;
global using SharpGrip.FluentValidation.AutoValidation.Endpoints.Results;