Skip to content

Commit 824a27c

Browse files
Merge pull request #160 from intelops/otel-db-integration
enhanncement: added opentel integration in db, rest and grpc
2 parents bb76c25 + 228a23d commit 824a27c

File tree

3 files changed

+535
-512
lines changed

3 files changed

+535
-512
lines changed

core/internal/languages/golang/frameworks/go-grpc-server/copier.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
const APIPath = "/api/v1"
2020

21+
const ConfigPath = "/config"
2122
const GrpcServerPath = "/pkg/grpc/server"
2223
const GrpcClientPath = "/pkg/grpc/client"
2324

@@ -53,6 +54,7 @@ const MySQLGORMDBConfigFile = "mysql-gorm.go.tmpl"
5354
const SQLiteGORMDBConfigFile = "sqlite-gorm.go.tmpl"
5455

5556
const ClientFile = "client.go.tmpl"
57+
const ConfigFile = "opentel-config.go.tmpl"
5658

5759
// MongoDB nosql databases
5860
const MongoDB = "MongoDB"
@@ -156,11 +158,15 @@ func (c *Copier) createGrpcClientDirectories() error {
156158

157159
// createGrpcServerDirectories creates grpc server directories.
158160
func (c *Copier) createGrpcServerDirectories() error {
161+
configDirectory := c.NodeDirectoryName + ConfigPath
159162
apiDirectory := c.NodeDirectoryName + APIPath
160163
controllersDirectory := c.NodeDirectoryName + ControllersPath
161164
modelsDirectory := c.NodeDirectoryName + ModelsPath
162165
servicesDirectory := c.NodeDirectoryName + ServicesPath
163166
daosDirectory := c.NodeDirectoryName + DaosPath
167+
if err := utils.CreateDirectories(configDirectory); err != nil {
168+
return err
169+
}
164170
if err := utils.CreateDirectories(apiDirectory); err != nil {
165171
return err
166172
}
@@ -655,6 +661,23 @@ func (c *Copier) CreateGrpcServer() error {
655661
return err
656662
}
657663
}
664+
665+
// copy opentel config file
666+
var filePaths []string
667+
// client files
668+
targetOpenTelConfigFileName := c.NodeDirectoryName + ConfigPath + "/" + ConfigFile
669+
_, err := utils.CopyFile(targetOpenTelConfigFileName, c.TemplatesRootPath+ConfigPath+"/"+ConfigFile)
670+
if err != nil {
671+
log.Debugf("error copying opentel config file: %v", err)
672+
return err
673+
}
674+
filePaths = append(filePaths, targetOpenTelConfigFileName)
675+
err = executor.Execute(filePaths, c.Data)
676+
if err != nil {
677+
log.Debugf("error executing opentel config file: %v", err)
678+
return err
679+
}
680+
658681
if c.IsSQLDB {
659682
// create sql db config file (common to all resources for specific database)
660683
// No vars in config file as of now but in future they may be there.

core/templates/compage-template-go

Submodule compage-template-go updated 26 files

0 commit comments

Comments
 (0)