Skip to content

Commit 9bbbb0a

Browse files
committed
Initial Release
1 parent 8193889 commit 9bbbb0a

22 files changed

Lines changed: 1998 additions & 0 deletions

samples/VB6Sample/Form1.frm

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
VERSION 5.00
2+
Begin VB.Form Form1
3+
Caption = "AppDynamics VB6 Wrapper Simple Test"
4+
ClientHeight = 3210
5+
ClientLeft = 120
6+
ClientTop = 465
7+
ClientWidth = 4935
8+
LinkTopic = "Form1"
9+
ScaleHeight = 3210
10+
ScaleWidth = 4935
11+
StartUpPosition = 3 'Windows Default
12+
Begin VB.TextBox Text1
13+
Height = 285
14+
Left = 1800
15+
TabIndex = 2
16+
Text = "1500"
17+
Top = 240
18+
Width = 1335
19+
End
20+
Begin VB.CommandButton Command2
21+
Caption = "BT 2 - Cash Withdraw"
22+
Height = 855
23+
Left = 960
24+
TabIndex = 1
25+
Top = 2040
26+
Width = 2775
27+
End
28+
Begin VB.CommandButton Command1
29+
Caption = "BT1 - Login"
30+
Height = 855
31+
Left = 960
32+
TabIndex = 0
33+
Top = 840
34+
Width = 2775
35+
End
36+
End
37+
Attribute VB_Name = "Form1"
38+
Attribute VB_GlobalNameSpace = False
39+
Attribute VB_Creatable = False
40+
Attribute VB_PredeclaredId = True
41+
Attribute VB_Exposed = False
42+
43+
44+
Dim rv As Variant
45+
46+
47+
48+
Private Sub Command1_Click()
49+
50+
Dim tokenBT, tokenExitCall As String
51+
tokenBT = GetGUID
52+
tokenExitCall = GetGUID
53+
Dim valor As String
54+
valor = Text1.Text
55+
56+
'Start the Business Transaction Execution for Cash WithDraw Transaction
57+
rv = AppD_StartBT("Login", "NullCorrelation", tokenBT)
58+
59+
'---
60+
'Your code would be here
61+
'---
62+
63+
'Declare the Database Backend
64+
rv = AppD_BackEndDeclare("DB", "SQLPRD06")
65+
rv = AppD_SetIdentifyingProperty("SQLPRD06", "HOST", "SQLPRD06.company.com")
66+
rv = AppD_SetIdentifyingProperty("SQLPRD06", "PORT", "1433")
67+
rv = AppD_SetIdentifyingProperty("SQLPRD06", "DATABASE", "DBUsuarios")
68+
rv = AppD_SetIdentifyingProperty("SQLPRD06", "VENDOR", "Microsoft")
69+
rv = AppD_BackendAdd("SQLPRD06")
70+
71+
'Start the Exit Call (DB) Execution
72+
rv = AppD_ExitCallBegin(tokenBT, tokenExitCall, "SQLPRD06")
73+
rv = AppD_ExitCallSetDetails(tokenExitCall, "SELECT USERNAME FROM AUTHENTICATION WHERE USERNAME=JOHN")
74+
75+
Sleep Val(valor) 'Sleep to simulate a query execution/slowness
76+
77+
78+
'Terminate the Exit Call Execution
79+
rv = AppD_ExitCallEnd(tokenExitCall)
80+
81+
'---
82+
' Your code would terminate here
83+
'---
84+
85+
' Terminate the Business Transaction Execution
86+
rv = AppD_EndBT(tokenBT)
87+
88+
89+
End Sub
90+
91+
Private Sub Command2_Click()
92+
Dim number As Integer
93+
For number = 1 To 10
94+
Dim tokenBT, tokenExitCall As String
95+
tokenBT = GetGUID
96+
tokenExitCall = GetGUID
97+
Dim valor As String
98+
valor = Text1.Text
99+
100+
'Start the Business Transaction Execution for Cash WithDraw Transaction
101+
rv = AppD_StartBT("Cash Withdraw", "NullCorrelation", tokenBT)
102+
103+
'---
104+
'Your code would be here
105+
'---
106+
107+
'Declare the Database Backend
108+
rv = AppD_BackEndDeclare("DB", "SQLPRD05")
109+
rv = AppD_SetIdentifyingProperty("SQLPRD05", "HOST", "SQLPRD05.company.com")
110+
rv = AppD_SetIdentifyingProperty("SQLPRD05", "PORT", "1433")
111+
rv = AppD_SetIdentifyingProperty("SQLPRD05", "DATABASE", "DBUsuarios")
112+
rv = AppD_BackendAdd("SQLPRD05")
113+
114+
'Start the Exit Call (DB) Execution
115+
rv = AppD_ExitCallBegin(tokenBT, tokenExitCall, "SQLPRD05")
116+
rv = AppD_ExitCallSetDetails(tokenExitCall, "SELECT * FROM USERS WHERE USERNAME=JOHN")
117+
118+
Sleep Val(valor) 'Sleep to simulate a query execution/slowness
119+
120+
'Terminate the Exit Call Execution
121+
rv = AppD_ExitCallEnd(tokenExitCall)
122+
123+
124+
'---
125+
' Your code would terminate here
126+
'---
127+
128+
' Terminate the Business Transaction Execution
129+
rv = AppD_EndBT(tokenBT)
130+
131+
Next
132+
133+
End Sub
134+
135+
Private Sub Form_Load()
136+
137+
rv = AppD_Initialize("controllerhost.appdynamics.com", 8090, 0, "account_name", "account_key", "Application_Name", "Tier_Name", "Node_Name", "c:\\appdlib\\")
138+
139+
End Sub

samples/VB6Sample/MSSCCPRJ.SCC

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[SCC]
2+
SCC=This is a source code control file
3+
[Project1.vbp]
4+
SCC_Project_Name=this project is not under source code control
5+
SCC_Aux_Path=<This is an empty string for the mssccprj.scc file>

samples/VB6Sample/Project1.vbp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Type=Exe
2+
Form=Form1.frm
3+
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
4+
Module=AppDynamics; mdlAppd.bas
5+
IconForm="Form1"
6+
Startup="Form1"
7+
Command32=""
8+
Name="Project1"
9+
HelpContextID="0"
10+
CompatibleMode="0"
11+
MajorVer=1
12+
MinorVer=0
13+
RevisionVer=0
14+
AutoIncrementVer=0
15+
ServerSupportFiles=0
16+
VersionCompanyName="A"
17+
CompilationType=0
18+
OptimizationType=0
19+
FavorPentiumPro(tm)=0
20+
CodeViewDebugInfo=0
21+
NoAliasing=0
22+
BoundsCheck=0
23+
OverflowCheck=0
24+
FlPointCheck=0
25+
FDIVCheck=0
26+
UnroundedFP=0
27+
StartMode=0
28+
Unattended=0
29+
Retained=0
30+
ThreadPerObject=0
31+
MaxNumberOfThreads=1

samples/VB6Sample/Project1.vbw

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Form1 = 132, 277, 1427, 1005, , 26, 26, 1321, 754, C
2+
AppDynamics = 99, 205, 1394, 933, Z

samples/VB6Sample/mdlAppd.bas

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Attribute VB_Name = "AppDynamics"
2+
'Guid Generation Libs
3+
Public Declare Sub CoCreateGuid Lib "ole32.dll" (ByRef pguid As Guid)
4+
Public Declare Function StringFromGUID2 Lib "ole32.dll" (ByVal rguid As Long, ByVal lpsz As Long, ByVal cchMax As Long) As Long
5+
6+
'Sleep
7+
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
8+
9+
'AppDynamics Functions
10+
Public Declare Function AppD_Initialize Lib "c:\\appdlib\\appdWrapper.dll" (ByVal controller_host As String, ByVal controller_port As Integer, ByVal controller_use_ssl As Integer, _
11+
ByVal controller_acct As String, ByVal controller_key As String, ByVal app As String, ByVal tier As String, ByVal node As String, ByVal logdir As String) As Long
12+
Public Declare Function AppD_Terminate Lib "c:\\appdlib\\appdWrapper.dll" () As Integer
13+
Public Declare Function AppD_StartBT Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BTName As String, ByVal CorrelationHeader As String, ByVal Guid As String) As Integer
14+
Public Declare Function AppD_EndBT Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BTHandle As String) As Integer
15+
Public Declare Function AppD_BackEndDeclare Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BackendType As String, ByVal UnregistredName As String) As Integer
16+
Public Declare Function AppD_SetIdentifyingProperty Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BackEnd As String, ByVal Key As String, ByVal Value As String) As Integer
17+
Public Declare Function AppD_BackendAdd Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BackEnd As String) As Integer
18+
Public Declare Function AppD_ExitCallBegin Lib "c:\\appdlib\\appdWrapper.dll" (ByVal BTHandleGuid As String, ByVal ExitCallGuid As String, ByVal BackEnd As String) As Integer
19+
Public Declare Function AppD_ExitCallEnd Lib "c:\\appdlib\\appdWrapper.dll" (ByVal ExitCallGuid As String) As Integer
20+
Public Declare Function AppD_ExitCallSetDetails Lib "c:\\appdlib\\appdWrapper.dll" (ByVal ExitCallGuid As String, ByVal Details As String) As Integer
21+
22+
Public Type Guid
23+
Data1 As Long
24+
Data2 As Integer
25+
Data3 As Integer
26+
Data4(0 To 7) As Byte
27+
End Type
28+
29+
' Guid Generation Function. An enhancement would be transfer this to the C++ DLL.
30+
31+
Public Function GetGUID() As String
32+
Dim MyGUID As Guid
33+
Dim GUIDByte() As Byte
34+
Dim GuidLen As Long
35+
36+
CoCreateGuid MyGUID
37+
38+
ReDim GUIDByte(80)
39+
GuidLen = StringFromGUID2(VarPtr(MyGUID.Data1), VarPtr(GUIDByte(0)), UBound(GUIDByte))
40+
41+
GetGUID = Left(GUIDByte, GuidLen)
42+
End Function
43+
16.5 KB
Binary file not shown.
35 MB
Binary file not shown.
21.8 MB
Binary file not shown.

src/appdWrapper/appdWrapper.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#include "stdafx.h"
2+
#include "appdynamics.h"
3+
#include <stdio.h>
4+
#include <objbase.h>
5+
6+
#define appdWrapper_EXPORTS
7+
#include "appdWrapper.h"
8+
9+
10+
int __stdcall AppD_Initialize(const char* controller_host, const unsigned short controller_port, const unsigned int controller_use_ssl, const char* controller_acct, const char* controller_key,
11+
const char* app, const char* tier, const char* node, const char* dir_logs)
12+
{
13+
int returnValue = 0;
14+
15+
appd_config *cfg = appd_config_init();
16+
17+
appd_config_getenv(cfg, NULL);
18+
19+
20+
// Controller settings
21+
appd_config_set_controller_host(cfg,controller_host);
22+
appd_config_set_controller_port(cfg,controller_port);
23+
appd_config_set_controller_use_ssl(cfg, controller_use_ssl);
24+
appd_config_set_controller_account(cfg, controller_acct);
25+
appd_config_set_controller_access_key(cfg, controller_key);
26+
27+
// App Model settings
28+
appd_config_set_app_name(cfg, app);
29+
appd_config_set_tier_name(cfg, tier);
30+
appd_config_set_node_name(cfg, node);
31+
32+
// Log settings
33+
appd_config_set_logging_min_level(cfg, appd_config_log_level(APPD_LOG_LEVEL_DEBUG));
34+
appd_config_set_logging_log_dir(cfg, dir_logs);
35+
36+
// This calls initializes the agent
37+
int initRC = appd_sdk_init(cfg);
38+
return initRC;
39+
}
40+
41+
void __stdcall AppD_Terminate() {
42+
43+
appd_sdk_term();
44+
}
45+
//Start a Business Transaction Execution.
46+
int __stdcall AppD_StartBT(const char* name, const char* correlation_header, const char* guid) {
47+
48+
appd_bt_handle btHandle = appd_bt_begin(name, correlation_header);
49+
50+
appd_bt_store(btHandle, guid);
51+
52+
return 0;
53+
54+
}
55+
56+
//End a Business Transaction Execution
57+
void __stdcall AppD_EndBT(const char* handle) {
58+
59+
appd_bt_handle btHandle = appd_bt_get(handle);
60+
appd_bt_end(btHandle);
61+
}
62+
63+
//Declare a BackEnd
64+
void __stdcall AppD_BackEndDeclare(const char* type, const char* unregistered_name) {
65+
66+
//Types can be HTTP, DB, CACHE, RABBITMQ, WEBSERVICE, JMS, WEBSPHERE_MQ
67+
appd_backend_declare(type, unregistered_name);
68+
}
69+
70+
//Set properties to a Declared Backend, for example an URL for a Webservice or DB Instance
71+
int __stdcall AppD_SetIdentifyingProperty(const char* backend, const char* key, const char* value) {
72+
73+
int ret;
74+
ret = appd_backend_set_identifying_property(backend, key, value);
75+
return ret;
76+
}
77+
78+
//Add a Backend
79+
int __stdcall AppD_BackendAdd(const char* backend) {
80+
81+
int ret;
82+
ret = appd_backend_add(backend);
83+
return ret;
84+
}
85+
86+
//Begin an Exit Call
87+
void __stdcall AppD_ExitCallBegin(const char* bthandleid, const char* exitcallguid, const char* backend) {
88+
appd_bt_handle bt = appd_bt_get(bthandleid);
89+
appd_exitcall_handle exitCall = appd_exitcall_begin(bt, backend);
90+
appd_exitcall_store(exitCall, exitcallguid);
91+
}
92+
93+
//End an Exit Call
94+
void __stdcall AppD_ExitCallEnd(const char* exitcallguid) {
95+
appd_exitcall_handle exitCall = appd_exitcall_get(exitcallguid);
96+
appd_exitcall_end(exitCall);
97+
}
98+
99+
//Set details for an exit call. For example the SQL Statement for a Database Exit Call.
100+
int __stdcall AppD_ExitCallSetDetails(const char* exitcallguid, const char* details) {
101+
int ret;
102+
appd_exitcall_handle exitCall = appd_exitcall_get(exitcallguid);
103+
ret = appd_exitcall_set_details(exitCall, details);
104+
return ret;
105+
}

src/appdWrapper/appdWrapper.def

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; appdWrapper.def - defines the exports for appdWrapper.dll
2+
3+
LIBRARY appdWrapper
4+
5+
EXPORTS
6+
7+
8+
AppD_Initialize
9+
AppD_Terminate
10+
AppD_StartBT
11+
AppD_EndBT
12+
AppD_BackEndDeclare
13+
AppD_SetIdentifyingProperty
14+
AppD_BackendAdd
15+
AppD_ExitCallBegin
16+
AppD_ExitCallEnd
17+
AppD_ExitCallSetDetails
18+
19+

0 commit comments

Comments
 (0)